/* ============================================================
   GUSTUX — Canonical signed-in / signed-out header
   Used by every member-facing Site page so the top toolbar
   never flickers between routes.
   ============================================================ */

:root {
  --ink: #0c0e14;
  --ink-soft: #14171f;
  --marble: #181c25;
  --vein: rgba(201,168,107,0.18);
  --vein-strong: rgba(201,168,107,0.32);
  --brass: #c9a86b;
  --brass-light: #d9bd84;
  --brass-deep: #8c6f3d;
  --ivory: #f1eadb;
  --bone: #cfc4b0;
  --sepia: #8a7f6a;
}

.gus-masthead {
  border-bottom: 1px solid var(--vein);
  padding: 18px 32px 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  background: var(--ink);
  position: relative;
  z-index: 50;
}

.gus-masthead-date {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--sepia);
  letter-spacing: 0.3px;
  justify-self: start;
}
.gus-masthead-date strong {
  font-style: normal;
  color: var(--bone);
  font-weight: 400;
}

.gus-masthead-brand,
a.gus-masthead-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--ivory);
  letter-spacing: 8px;
  text-align: center;
  line-height: 1;
  text-decoration: none;
  text-indent: 8px;
}
.gus-masthead-brand .sub {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  font-weight: 400;
  color: var(--sepia);
  letter-spacing: 4px;
  margin-top: 6px;
  text-transform: uppercase;
  text-indent: 0;
}

.gus-masthead-user {
  justify-self: end;
  display: none;
  align-items: center;
  gap: 16px;
}
.gus-masthead-user.gus-active { display: flex; }

.gus-open-app-btn {
  background: var(--brass);
  color: var(--ink);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.2px;
  padding: 7px 14px;
  margin-right: 6px;
  border: 1px solid var(--brass);
  transition: background 0.15s;
  text-decoration: none;
}
.gus-open-app-btn:hover { background: var(--brass-light); color: var(--ink); }

.gus-user-bell {
  position: relative;
  color: var(--bone);
  font-size: 16px;
  padding: 6px 8px;
  cursor: pointer;
  text-decoration: none;
}
.gus-user-bell:hover { color: var(--ivory); }
.gus-user-bell .badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--brass);
  color: var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  line-height: 1.2;
}

.gus-user-name {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 15px;
  color: var(--ivory);
}

.gus-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brass-light), var(--brass-deep));
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0;
  border: 1px solid var(--brass);
}

.gus-user-signout {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--sepia);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 1px solid var(--vein);
  text-decoration: none;
  background: transparent;
  cursor: pointer;
}
.gus-user-signout:hover { border-color: var(--brass); color: var(--bone); }

/* Signed-out variant — same right cluster slot, different children */
.gus-signin-link {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--sepia);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 6px 10px;
  text-decoration: none;
}
.gus-signin-link:hover { color: var(--ivory); }

.gus-apply-cta {
  background: var(--brass);
  color: var(--ink);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  padding: 7px 14px;
  border: 1px solid var(--brass);
  text-decoration: none;
  transition: background 0.15s;
}
.gus-apply-cta:hover { background: var(--brass-light); }

/* Admin badge slot — appears next to brand on /admin/* */
.gus-admin-badge {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--brass);
  text-transform: uppercase;
  border: 1px solid var(--brass);
  padding: 3px 10px;
  margin-left: 14px;
  vertical-align: middle;
}

@media (max-width: 720px) {
  /* COMPACT MASTHEAD — brand on the left, avatar on the right, one row.
     Date / bell / name / Sign Out all hide and move into the avatar drawer.
     Reclaims ~91px of vertical space on the journal and every signed-in page. */
  .gus-masthead {
    grid-template-columns: 1fr auto !important;
    gap: 0 !important;
    text-align: left !important;
    padding: 10px 16px !important;
    padding-top: calc(10px + env(safe-area-inset-top, 0px)) !important;
  }
  .gus-masthead-date { display: none !important; }
  .gus-masthead-brand,
  a.gus-masthead-brand {
    font-size: 20px !important;
    letter-spacing: 3px !important;
    text-align: left !important;
    justify-self: start !important;
    text-indent: 3px !important;
    display: flex !important;
    align-items: baseline !important;
    gap: 8px !important;
  }
  .gus-masthead-brand .sub {
    display: inline-block !important;
    margin-top: 0 !important;
    font-size: 8px !important;
    letter-spacing: 2px !important;
  }
  .gus-masthead-user {
    justify-self: end !important;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    gap: 6px !important;
  }
  .gus-user-bell,
  .gus-user-name,
  .gus-user-signout { display: none !important; }
  /* Open the Journal button STAYS visible on mobile — compact sizing so it
     fits in the single-row mobile masthead. Per Kingmaker: the gold CTA is
     the primary entry into /app and should never disappear on small screens. */
  .gus-open-app-btn {
    font-size: 11px !important;
    padding: 5px 9px !important;
    margin-right: 4px !important;
    letter-spacing: 0 !important;
    line-height: 1.1 !important;
  }
  .gus-user-avatar { width: 30px; height: 30px; font-size: 14px; }
}
@media (max-width: 380px) {
  /* On the smallest phones, abbreviate the label so the button still fits */
  .gus-open-app-btn { font-size: 10px !important; padding: 5px 7px !important; }
}

/* ============================================================
   SECTION NAV — shared experience-led nav, injected by
   gus-header.js on signed-in pages. Active set by current path.
   ============================================================ */
.section-nav {
  border-bottom: 1px solid var(--vein);
  padding: 0 32px;
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(6px);
}
.section-nav-inner {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 1400px;
  margin: 0 auto;
  scrollbar-width: none;
}
.section-nav-inner::-webkit-scrollbar { display: none; }
.section-link {
  padding: 14px 18px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 2.5px;
  color: var(--bone);
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.section-link:hover { color: var(--ivory); }
.section-link.active {
  color: var(--brass);
  border-bottom-color: var(--brass);
}

/* ============================================================
   iOS / iPhone hardening (shared across pages using this header)
   ============================================================ */
body { -webkit-tap-highlight-color: transparent; }
.gus-masthead { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
.section-nav { top: env(safe-area-inset-top, 0px); }
.section-nav-inner { -webkit-overflow-scrolling: touch; }
.gus-user-bell, .gus-user-signout, .gus-signin-link { min-height: 44px; display: inline-flex; align-items: center; }
@media (max-width: 720px) {
  input, textarea, select { font-size: 16px !important; } /* prevent iOS focus-zoom */
}

/* ============================================================
   AVATAR TAP-DRAWER — re-homes the elements that the compact
   mobile masthead hides (date, notifications, profile, settings,
   sign-out). Injected by gus-header.js on signed-in pages.
   Always available; visually relevant on mobile.
   ============================================================ */
.gus-user-avatar { cursor: pointer; transition: box-shadow 0.15s ease; }
.gus-user-avatar.gus-avatar-active {
  box-shadow: 0 0 0 2px rgba(201,168,107,0.4);
}
.gus-user-avatar.gus-avatar-has-unread::after {
  content: ""; position: absolute;
  top: -2px; right: -2px;
  width: 8px; height: 8px;
  background: var(--brass);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  pointer-events: none;
}
.gus-masthead-user { position: relative; }

.gus-user-drawer {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  background: rgba(20, 23, 31, 0.97);
  border: 1px solid rgba(201,168,107,0.34);
  border-radius: 6px;
  padding: 8px 0;
  z-index: 60;
  box-shadow: 0 12px 28px -8px rgba(0,0,0,0.6);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  display: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.gus-user-drawer.open {
  display: block;
  opacity: 1;
  transform: translateY(0);
}
.gus-drawer-date {
  padding: 8px 16px 6px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 12px;
  color: var(--sepia);
}
.gus-drawer-sep { height: 1px; background: rgba(201,168,107,0.18); margin: 4px 0; }
.gus-drawer-section-label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 4px;
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 1.8px;
  color: var(--brass);
  text-transform: uppercase;
}
.gus-drawer-section-label::after {
  content: ""; flex: 1; height: 1px; background: rgba(201,168,107,0.18);
}
.gus-drawer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: var(--bone);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.gus-drawer-row:hover { background: rgba(201,168,107,0.06); color: var(--ivory); }
.gus-drawer-glyph { width: 16px; opacity: 0.75; font-size: 14px; text-align: center; flex-shrink: 0; }
.gus-drawer-badge {
  margin-left: auto;
  background: var(--brass);
  color: var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  display: none;
  line-height: 1.3;
}
.gus-drawer-badge.has-count { display: inline-block; }
.gus-drawer-signout {
  color: #d4824a;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.gus-drawer-signout:hover { color: #e0a26e; }
.gus-drawer-signout .gus-drawer-glyph { opacity: 0.85; }
