/* ==========================================================
   Grimoire header (fixed) + layout
   ========================================================== */

.grimoire-header {
  /* Wood palette */
  --wood-1: #24150f; /* deep */
  --wood-2: #2f1c14; /* base */
  --wood-3: #3c2419; /* warm highlight */
  --wood-4: #1a100b; /* edge shadow */

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4rem;
  z-index: 1000;

  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;

  padding: 0 1rem;
  overflow: hidden;

  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  color: #f2e6d2; /* parchment/ivory text on wood */

  /* Wood grain: long grain + tonal waves + subtle sheen */
  background-color: var(--wood-2);
  background-image:
    /* top sheen */
    linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.10),
      rgba(255, 255, 255, 0.02) 35%,
      transparent 80%
    ),

    /* broad tonal waves */
    linear-gradient(
      90deg,
      var(--wood-4),
      var(--wood-2) 14%,
      var(--wood-3) 32%,
      var(--wood-2) 56%,
      var(--wood-1) 78%,
      var(--wood-4)
    ),

    /* fine grain streaks */
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.035) 0px,
      rgba(255, 255, 255, 0.035) 2px,
      rgba(0, 0, 0, 0.08) 3px,
      rgba(0, 0, 0, 0.08) 6px
    );

  background-blend-mode: overlay, normal, multiply;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.55),
    0 10px 18px rgba(0, 0, 0, 0.35);
}

/* Organic noise overlay to avoid “striped wallpaper” look */
.grimoire-header::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.14; /* tweak 0.08–0.18 */
  mix-blend-mode: overlay;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='360' height='160' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  background-size: 360px 160px;
}

/* Ensure header content stays above the overlay */
.grimoire-header > * {
  position: relative;
  z-index: 1;
}

/* Column alignment helpers */
.grimoire-header__left {
  justify-self: start;
}

.grimoire-header__center {
  justify-self: center;
  width: 100%;
  max-width: 600px;
}

.grimoire-header__right {
  justify-self: end;
}

/* Optional: links/buttons on wood */
.grimoire-header a,
.grimoire-header button {
  color: #f2e6d2;
}

/* ==========================================================
   Brand / logo
   ========================================================== */

.grimoire-brand {
  display: flex;
  align-items: center;
  line-height: 0; /* removes extra inline-image whitespace */
}

.grimoire-brand img.site-logo {
  height: calc(100% - 0.75rem); /* fits within 4rem header w/ breathing room */
  max-height: 3rem;             /* safety cap if header height changes */
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

/* ==========================================================
   Search input (carved slot)
   ========================================================== */

.grimoire-search__input {
  width: 100%;
  padding: 0.55rem 0.75rem;

  color: #1e140e;
  background: rgba(245, 231, 206, 0.92); /* parchmenty input */
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 10px;

  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

.grimoire-search__input::placeholder {
  color: rgba(40, 25, 15, 0.55);
}

/* ==========================================================
   Responsive (≤ 768px)
   ========================================================== */

@media (max-width: 768px) {
  .grimoire-header {
    height: auto; /* allow expansion */
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    gap: 0.4rem 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .grimoire-header__left {
    grid-column: 1;
    grid-row: 1;

    display: flex;
    align-items: center;
    gap: 0.5rem; /* space between logo and hamburger */
  }

  .grimoire-header__right {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .grimoire-header__center {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: 100%;
  }

  .grimoire-brand img.site-logo {
    height: calc(100% - 0.6rem);
    max-height: 2.6rem;
  }

  .grimoire-search__input {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  .dm-switch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
  }

  .dm-switch__label {
    font-size: 0.7rem;
    line-height: 1;
  }

  .nav-toggle {
    margin: 0;
  }
}
