/* ================================================================
   header.css — sticky site header, logo, search bar, avatar,
                advanced search panel, category bar, how-tos
   ================================================================ */

/* ── STICKY HEADER ──────────────────────────────────────────────── */
.site-header {
  background: var(--rd);
  border-bottom: 3px solid var(--go);
  position: sticky;
  top: 0;
  z-index: 100;
}
.hdr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--sp-lg);
  height: 80px;
  gap: var(--sp-md);
}

/* ── LOGO ───────────────────────────────────────────────────────── */
.logo {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  font-size: var(--logo-size);   /* size anchor — name & slogan scale from this */
}
.logo-name {
  font-family: var(--heading-font);
  font-size: 1em;                /* = --logo-size */
  color: var(--pa);
  font-style: italic;
}
.logo-name strong { color: var(--gl); font-style: normal; }
.logo-slogan {
  font-size: 0.67em;             /* locked ratio to the logo name */
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--go);
  opacity: .8;
}
.logo-slogan .dot { color: #C94040; margin: 0 3px; }

/* ── HEADER SEARCH ──────────────────────────────────────────────── */
.hdr-search {
  flex: 1;
  min-width: 0;        /* allow the search to shrink so the nav (avatar +
                          add buttons) is never pushed off-screen / clipped */
  max-width: 480px;
  position: relative;
}
.search-row {
  display: flex;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(201,168,76,.4);
  border-radius: var(--r-md);
  overflow: visible;
  position: relative;
}
.search-row input {
  flex: 1;
  border: none;
  padding: 8px 14px;
  font-family: var(--body-font);
  font-size: 14.3px;
  color: #fff;
  background: transparent;
  outline: none;
  min-width: 0;
  border-radius: var(--r-md) 0 0 var(--r-md);
}
.search-row input::placeholder { color: rgba(255,255,255,.5); }
.search-row input:focus         { background: rgba(255,255,255,.08); }

.btn-search {
  background: var(--go);
  border: none;
  color: var(--rd);
  padding: 0 14px;
  cursor: pointer;
  font-size: 15.4px;
  font-weight: 700;
  transition: background .15s;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.btn-search:hover { background: var(--gl); }

/* ── AUTOCOMPLETE ───────────────────────────────────────────────── */
.autocomplete-box {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--bs);
  border-radius: var(--r-md);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  z-index: 300;
  display: none;
  overflow: hidden;
}
.autocomplete-box.open { display: block; }
.ac-item {
  padding: 8px 14px;
  font-size: 14.3px;
  color: var(--im);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .1s;
}
.ac-item:hover, .ac-item.ac-focused { background: var(--rp); color: var(--red); }
.ac-item i { font-size: 13.2px; color: var(--muted); }

/* ── ADVANCED SEARCH PANEL ──────────────────────────────────────── */
.adv-panel {
  background: var(--rd);
  border-top: 1px solid rgba(201,168,76,.2);
  padding: var(--sp-md) var(--sp-lg);
  display: none;
}
.adv-panel.open { display: block; }
.adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}
.adv-field label {
  display: block;
  font-size: 9.9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--go);
  margin-bottom: 3px;
  opacity: .85;
}
.adv-field select,
.adv-field input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid rgba(201,168,76,.3);
  border-radius: var(--r-sm);
  font-family: var(--body-font);
  font-size: 13.2px;
  color: #fff;
  background: rgba(255,255,255,.1);
  outline: none;
}
.adv-field select option { background: var(--rd); }
.adv-field input::placeholder { color: rgba(255,255,255,.45); }

.adv-actions { display: flex; flex-direction: row; gap: var(--sp-xs); align-self: end; align-items: flex-end; white-space: nowrap; }
.adv-actions .btn { white-space: nowrap; }

/* ── HEADER NAV ─────────────────────────────────────────────────── */
.hdr-nav { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }

/* ── AVATAR ─────────────────────────────────────────────────────── */
.av-wrap    { position: relative; }
.av-circle  {
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--go);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--rm);
  font-family: var(--heading-font);
  font-size: 14.3px;
  color: var(--gl);
  font-weight: 700;
  flex-shrink: 0;
  transition: all .15s;
}
.av-circle:hover { border-color: #fff; transform: scale(1.05); }
.av-circle img   { width: 100%; height: 100%; object-fit: cover; }

.av-menu {
  position: absolute;
  top: 44px; right: 0;
  background: #fff;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: var(--r-xl);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 185px;
  z-index: 200;
  display: none;
  overflow: hidden;
}
.av-menu.open { display: block; }

.av-menu-header  { padding: .75rem 1rem .625rem; border-bottom: 1px solid var(--bo); background: var(--pa); }
.av-menu-name    { font-family: var(--heading-font); font-size: 14.3px; color: var(--rd); font-style: italic; font-weight: 700; }
.av-menu-role    { font-size: 9.9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 1px; }

.av-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem;
  font-size: 13.2px; color: var(--im);
  cursor: pointer;
  background: none; border: none;
  width: 100%; text-align: left;
  font-family: var(--body-font);
  transition: background .12s;
  text-decoration: none;
}
.av-item:hover    { background: #f8f5f0; text-decoration: none; }
.av-item-left     { display: flex; align-items: center; gap: .5rem; }
.av-item i        { font-size: 15.4px; color: var(--muted); }
.av-item:hover i  { color: var(--red); }
.av-item.danger   { color: var(--red); }
.av-item.danger i { color: var(--red); }

.av-kbd {
  font-size: 9.9px; color: var(--muted);
  background: var(--pa); padding: 1px 5px;
  border-radius: 3px; border: 1px solid var(--bo);
}
.av-divider { height: 1px; background: var(--bo); }

/* ── CATEGORY BAR ───────────────────────────────────────────────── */
.cat-bar-wrap { background: var(--pa); border-bottom: 1px solid var(--bo); position: relative; }
.cat-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: .7rem var(--sp-lg);
  flex-wrap: wrap;
}
.cat-label { font-size: 9.9px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-right: 3px; }

/* Circular back button, aligned with the left edge of the centred
   1100px content column (matches the logo / recipe content). */
.cat-back {
  position: absolute; left: max(var(--sp-lg), calc(50% - 550px + var(--sp-lg))); top: 50%;
  transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 30px; flex-shrink: 0;
  border-radius: var(--r-pill);
  background: #fff; color: var(--red);
  border: 1px solid var(--go);
  box-shadow: 0 1px 3px rgba(92,15,15,.15);
  font-size: 16px; line-height: 1;
  text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s, transform .15s, border-color .15s, box-shadow .15s;
}
.cat-back i { transition: transform .15s; }
.cat-back:hover {
  background: var(--red); border-color: var(--red);
  color: #fff; transform: translateY(-50%) scale(1.06);
  box-shadow: 0 2px 6px rgba(92,15,15,.28);
  text-decoration: none;
}
.cat-back:hover i { transform: translateX(-2px); }

.pill {
  padding: 4px 12.5px;
  border-radius: var(--r-pill);
  font-size: 12.6px;
  border: 1px solid var(--bs);
  cursor: pointer;
  font-family: var(--body-font);
  color: var(--im);
  background: #fff;
  transition: all .15s;
  white-space: nowrap;
  display: inline-flex; align-items: center;
  text-decoration: none;
}
.pill:hover, .pill.active { background: var(--red); color: #fff; border-color: var(--red); text-decoration: none; }

.cat-divider { width: 1px; height: 20px; background: var(--bs); margin: 0 4px; flex-shrink: 0; }

/* ── HOW-TOS DROPDOWN ───────────────────────────────────────────── */
.howto-wrap  { position: relative; }
.howto-btn {
  background: #fff; border: 1px solid var(--bs);
  padding: 4px 12.5px; border-radius: var(--r-pill);
  font-size: 12.6px; line-height: 1.6; cursor: pointer;
  font-family: var(--body-font); color: var(--im);
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap; transition: all .15s;
}
.howto-btn:hover, .howto-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
.howto-btn i { font-size: 13px; transition: transform .18s; }
.howto-btn.active i { transform: rotate(180deg); }

.howto-menu {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  background: var(--cr);
  border: 1px solid var(--bs);
  border-top: 3px solid var(--go);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  box-shadow: 0 8px 24px rgba(92,15,15,.15);
  min-width: 190px; z-index: 150;
  padding: .3rem 0;
  display: none; overflow: hidden;
}
.howto-menu.open { display: block; }
.howto-menu-label {
  padding: .25rem 1rem .45rem;
  font-size: 9.9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--bo);
  margin-bottom: .25rem;
}
.howto-item {
  display: block; padding: .45rem 1rem;
  font-size: 13.2px; color: var(--im);
  text-decoration: none; cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, padding .12s;
  border: none; width: 100%; text-align: left;
  font-family: var(--body-font); background: none;
}
.howto-item:hover { background: var(--rp); color: var(--red); padding-left: 1.25rem; }

/* ── ADV SEARCH BUTTON (icon only, next to search) ─────────────── */
.btn-adv-icon {
  background: rgba(255,255,255,.1);
  border: none;
  border-left: 1px solid rgba(201,168,76,.25);
  color: var(--gl);
  padding: 0 11px;
  cursor: pointer;
  font-size: 16.5px;
  transition: all .15s;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  flex-shrink: 0;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.btn-adv-icon:hover  { background: rgba(255,255,255,.2); color: #fff; }
.btn-adv-icon.active { background: var(--go); color: var(--rd); }
.btn-adv-icon .adv-dot {
  position: absolute; top: 5px; right: 5px;
  width: 6px; height: 6px;
  background: var(--go); border-radius: 50%;
  display: none;
}
.btn-adv-icon.has-filters .adv-dot { display: block; }

/* ── ADVANCED PANEL ─────────────────────────────────────────────── */
.adv-panel { background: var(--rd); border-top: 1px solid rgba(201,168,76,.2); padding: 2px var(--sp-lg) var(--sp-sm); display: none; }
.adv-panel.open { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.adv-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)) auto; gap: var(--sp-sm); margin: 0 auto 2px; width: 100%; max-width: 1320px; text-align: left; }
.adv-field label { display: block; font-size: 13.2px; letter-spacing: 0; text-transform: none; color: var(--go); margin-bottom: 3px; opacity: 1; white-space: nowrap; }
.adv-field select,
.adv-field input  { width: 100%; padding: 6px 9px; border: 1px solid rgba(201,168,76,.3); border-radius: var(--r-sm); font-family: var(--body-font); font-size: 13.2px; color: #fff; background: rgba(255,255,255,.1); outline: none; }
.adv-field select option { background: var(--rd); }
.adv-field input::placeholder { color: rgba(255,255,255,.45); }
.adv-actions { display: flex; flex-direction: row; gap: var(--sp-xs); align-self: end; align-items: flex-end; white-space: nowrap; }
.adv-actions .btn { white-space: nowrap; }

/* ── AUTOCOMPLETE ───────────────────────────────────────────────── */
.autocomplete-box { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--bs); border-radius: var(--r-md); box-shadow: 0 6px 20px rgba(0,0,0,.12); z-index: 300; display: none; overflow: hidden; }
.autocomplete-box.open { display: block; }
.ac-item { padding: 8px 14px; font-size: 14.3px; color: var(--im); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background .1s; }
.ac-item:hover, .ac-item.ac-focused { background: var(--rp); color: var(--red); }
.ac-item i { font-size: 13.2px; color: var(--muted); }

/* ── CATEGORY BROWSE TOGGLE (mobile only) ───────────────────────── */
/* On desktop the category bar shows inline, so the button is hidden.
   On mobile the bar is collapsed and this button — sitting on the
   right edge of the search row — expands it on demand. */
.btn-cat-toggle { display: none; }

@media (max-width: 768px) {
  /* Reveal the toggle and let it own the search row's right corner */
  .btn-cat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.1);
    border: none;
    border-left: 1px solid rgba(201,168,76,.25);
    color: var(--gl);
    padding: 0 12px;
    cursor: pointer;
    font-size: 16.5px;
    transition: all .15s;
    border-radius: 0 var(--r-md) var(--r-md) 0;
    flex-shrink: 0;
  }
  .btn-cat-toggle:hover  { background: rgba(255,255,255,.2); color: #fff; }
  .btn-cat-toggle.active { background: var(--go); color: var(--rd); }

  /* The adv-icon is no longer the rightmost button — square its corner */
  .btn-adv-icon { border-radius: 0; }

  /* Category bar collapsed by default; expand when toggled open */
  .cat-bar-wrap {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .4s cubic-bezier(.22, .61, .36, 1),
                opacity    .3s ease;
    will-change: max-height;
  }
  body.cats-open .cat-bar-wrap {
    max-height: 60vh;
    opacity: 1;
  }

  /* Avatar dropdown — pin to the viewport so a tall menu (admin has 7+
     items) can't run off the bottom of the screen, and cap its size so
     it never spills past the screen edges. Scroll internally if needed. */
  .av-menu {
    position: fixed;
    top: 70px;
    right: 8px;
    left: auto;
    min-width: 200px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 86px);
    max-height: calc(100dvh - 86px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
