/* ── RH2 Shared Styles ── applies to ALL portal pages
   Loads tokens.css FIRST so the editorial kit palette + type +
   spacing + radius are available on every page that imports
   shared.css. Per-page <style> blocks can use --ed-*, --font-heading,
   --sp-*, --r-*, etc. without each page needing its own <link>. */
@import url('/css/tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --gold: #f9b016;
  --gold-dark: #d9940f;
  --dark: #1a1a2e;
  --dark2: #16213e;
  --mid: #0f3460;
  --light: #f4f6f9;
  --text: #333;
  --muted: #666;
  --white: #fff;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}
body { font-family: 'Poppins', sans-serif; background: var(--light); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ── Top Nav (consistent across ALL pages — editorial brand) ── */
.rh2-nav {
  background: var(--ed-surface);
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 0.5px solid var(--ed-border);
}
.rh2-nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
}
/* Brand dot: keep the styled fallback for code-only contexts, BUT prefer
   the actual seal — rh2.js can swap the inner content to <img> on pages
   that load shared.css. Until that lands, the styled dot still renders
   tasteful editorial. */
.rh2-nav-dot {
  width: 36px; height: 36px;
  background: var(--ed-forest);
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 600;
  color: var(--ed-cream); font-size: 1rem; letter-spacing: -0.02em;
}
/* Brand seal img (preferred over the .rh2-nav-dot fallback). 36px
   matches the dot. Forest-on-cream at small sizes can read as faint;
   we render the higher-resolution 256 PNG at 36 to keep edges crisp. */
.rh2-nav-brand img { width: 36px; height: 36px; }
.rh2-nav-brand span {
  color: var(--ed-ink);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: var(--ls-tight);
}
.rh2-nav-brand span em {
  color: var(--ed-gold-deep);
  font-style: italic;
  font-weight: 500;
}
.rh2-nav-links {
  display: flex;
  gap: var(--sp-1);
  margin-left: var(--sp-6);
}
.rh2-nav-links a {
  color: var(--ed-ink);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  padding: 6px 12px;
  border-radius: var(--r-sharp);
  transition: color var(--t-fast), background var(--t-fast);
  font-weight: 400;
}
.rh2-nav-links a:hover { color: var(--ed-gold-deep); background: transparent; text-decoration: none; }
.rh2-nav-links a.active { color: var(--ed-ink); background: var(--ed-gold-wash); font-weight: 500; }
.rh2-nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.rh2-nav-user { color: var(--ed-gold-deep); font-size: var(--fs-small); font-weight: 500; }
.rh2-nav-signout {
  background: transparent;
  border: 1px solid var(--ed-border);
  color: var(--ed-ink);
  padding: 5px 14px;
  border-radius: var(--r-sharp);
  cursor: pointer;
  font-size: var(--fs-xs);
  font-family: inherit;
  transition: border-color var(--t-fast);
}
.rh2-nav-signout:hover { border-color: var(--ed-ink); }
.rh2-nav-signin {
  background: var(--ed-forest);
  color: var(--ed-cream);
  padding: 7px 16px;
  border-radius: var(--r-sharp);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-decoration: none;
  letter-spacing: var(--ls-wide);
  transition: background var(--t-fast);
}
.rh2-nav-signin:hover { background: var(--ed-forest-dark); }

/* ── Main Content ── */
.rh2-main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }
.rh2-title { font-size: 1.4rem; font-weight: 700; color: var(--dark); margin-bottom: 4px; }
.rh2-subtitle { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }

/* ── Stats Row ── */
.rh2-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.rh2-stat { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; border-left: 4px solid var(--gold); }
.rh2-stat .val { font-size: 1.7rem; font-weight: 700; color: var(--dark); }
.rh2-stat .lbl { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.rh2-stat.green { border-left-color: var(--green); }
.rh2-stat.green .val { color: var(--green); }
.rh2-stat.blue { border-left-color: var(--blue); }
.rh2-stat.red { border-left-color: var(--red); }

/* ── Card ── */
.rh2-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.25rem; }
.rh2-card-h { font-size: 0.9rem; font-weight: 600; color: var(--dark); margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--gold); display: flex; align-items: center; justify-content: space-between; }

/* ── Table ── */
.rh2-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.rh2-table th { text-align: left; padding: 8px 10px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-bottom: 2px solid #f0f0f0; }
.rh2-table td { padding: 8px 10px; border-bottom: 1px solid #f8f8f8; }
.rh2-table tr:hover td { background: #fafafa; }

/* ── Buttons ── */
.rh2-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-weight: 500; font-size: 0.8rem; cursor: pointer; border: none; font-family: inherit; transition: all 0.15s; }
.rh2-btn-gold { background: var(--gold); color: var(--dark); }
.rh2-btn-gold:hover { background: var(--gold-dark); }
.rh2-btn-outline { background: transparent; border: 1.5px solid #ddd; color: var(--text); }
.rh2-btn-sm { padding: 4px 10px; font-size: 0.72rem; }

/* ── Tags ── */
.rh2-tag { font-size: 0.68rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; display: inline-block; }
.rh2-tag-green { background: #dcfce7; color: #166534; }
.rh2-tag-gold { background: rgba(249,176,22,.12); color: #92400e; }
.rh2-tag-blue { background: #dbeafe; color: #1e40af; }
.rh2-tag-red { background: #fee2e2; color: #991b1b; }

/* ── Login Gate ── */
/* Login gate — editorial brand pass.
   Cream page bg, white card with hairline border + soft shadow,
   real seal slot at top via .rh2-login-seal, Cormorant heading
   with italic-gold accent, Montserrat body, forest CTA button.
   width:100% + min-height:calc(100vh - 56px) so the box centers
   vertically in the area BELOW the sticky nav, not against the
   full viewport (which was making it appear offset). */
.rh2-login-gate { width: 100%; min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; background: var(--ed-bg); padding: var(--sp-6) var(--sp-4); box-sizing: border-box; }
.rh2-login-box { background: var(--ed-surface); border: 0.5px solid var(--ed-border); border-radius: var(--r-sharp); padding: var(--sp-8) var(--sp-8); width: 100%; max-width: 420px; box-shadow: var(--sh-modal); text-align: center; box-sizing: border-box; }
.rh2-login-box .rh2-login-seal { width: 88px; height: 88px; display: block; margin: 0 auto var(--sp-4); }
.rh2-login-box h2 { font-family: var(--font-heading); font-size: 1.85rem; font-weight: 500; margin-bottom: var(--sp-1); letter-spacing: var(--ls-tight); color: var(--ed-ink); }
.rh2-login-box h2 em { color: var(--ed-gold-deep); font-style: italic; font-weight: 500; }
.rh2-login-box p { color: var(--ed-muted-2); font-size: var(--fs-small); margin-bottom: var(--sp-6); font-weight: 300; }
.rh2-login-box input { width: 100%; padding: 11px 14px; border: 0.5px solid var(--ed-border); border-radius: var(--r-sharp); font-family: var(--font-body); font-size: var(--fs-small); margin-bottom: var(--sp-2); outline: none; background: var(--ed-bg); color: var(--ed-ink); transition: border-color var(--t-fast), background var(--t-fast); }
.rh2-login-box input:focus { border-color: var(--ed-ink); background: var(--ed-surface); }
.rh2-login-error { background: var(--ed-red-tint); border: 0.5px solid var(--ed-red); color: var(--ed-red-ink); border-radius: var(--r-sharp); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); margin-bottom: var(--sp-2); display: none; text-align: left; }
.rh2-login-btn { width: 100%; padding: 12px; background: var(--ed-forest); color: var(--ed-cream); border: none; border-radius: var(--r-sharp); font-weight: 500; font-size: var(--fs-small); cursor: pointer; font-family: var(--font-body); letter-spacing: var(--ls-wide); margin-top: var(--sp-2); transition: background var(--t-fast); }
.rh2-login-btn:hover { background: var(--ed-forest-dark); }
.rh2-login-google { width: 100%; padding: 11px; background: var(--ed-surface); border: 0.5px solid var(--ed-border); color: var(--ed-ink); border-radius: var(--r-sharp); font-size: var(--fs-small); cursor: pointer; font-family: var(--font-body); margin-top: var(--sp-2); display: flex; align-items: center; justify-content: center; gap: var(--sp-2); transition: border-color var(--t-fast); }
.rh2-login-google:hover { border-color: var(--ed-ink); }

/* ── Empty state ── */
.rh2-empty { text-align: center; padding: 2rem; color: var(--muted); font-size: 0.85rem; }

/* ── Hamburger button ── always visible (not mobile-only). Opens the
   side drawer below. Sits at the far left of the top nav. */
.rh2-nav-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: 4px;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sharp);
  transition: background var(--t-fast);
}
.rh2-nav-hamburger:hover { background: var(--ed-bg); }
.rh2-nav-hamburger:focus { outline: 1px solid var(--ed-gold); outline-offset: 2px; }
.rh2-nav-hamburger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--ed-ink);
  margin: 2.5px 0;
  border-radius: 1px;
  transition: transform var(--t-fast), opacity var(--t-fast);
}

/* ── Side drawer ── slides in from the left. Holds the same nav links
   plus extras (Tools section) that don't fit on the top bar. */
.rh2-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}
.rh2-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.rh2-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 90vw;
  background: var(--ed-surface);
  border-right: 0.5px solid var(--ed-border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.25s ease-out;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.rh2-drawer.open { transform: translateX(0); }

.rh2-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 0.5px solid var(--ed-border);
}
.rh2-drawer-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ed-ink);
  letter-spacing: -0.005em;
}
.rh2-drawer-title em {
  color: var(--ed-gold);
  font-style: italic;
  font-weight: 500;
}
.rh2-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ed-muted-2);
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sharp);
  transition: color var(--t-fast), background var(--t-fast);
}
.rh2-drawer-close:hover { color: var(--ed-ink); background: var(--ed-bg); }

.rh2-drawer-user {
  padding: var(--sp-3) var(--sp-5);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ed-ink);
  border-bottom: 0.5px solid var(--ed-border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.rh2-drawer-role {
  font-size: 0.6rem;
  color: var(--ed-muted-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.rh2-drawer-section { padding: var(--sp-3) 0 var(--sp-2); }
.rh2-drawer-section-title {
  font-size: 0.6rem;
  color: var(--ed-muted-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  padding: var(--sp-2) var(--sp-5) var(--sp-1);
}
.rh2-drawer-section a {
  display: block;
  padding: 9px var(--sp-5);
  font-size: 0.88rem;
  color: var(--ed-ink);
  text-decoration: none;
  font-weight: 400;
  border-left: 2px solid transparent;
  transition: background var(--t-fast), border-left-color var(--t-fast);
}
.rh2-drawer-section a:hover {
  background: var(--ed-bg);
  border-left-color: var(--ed-gold);
}
.rh2-drawer-section a.active {
  border-left-color: var(--ed-ink);
  background: var(--ed-gold-wash);
  font-weight: 500;
}

/* ── Drawer mode toggle (bottom of drawer) ── lets the user pick
   between three nav layouts. Active mode persists in localStorage. */
.rh2-drawer-mode { margin-top: auto; padding-top: var(--sp-3); border-top: 0.5px solid var(--ed-border); }
.rh2-drawer-mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 var(--sp-5) var(--sp-4); }
.rh2-drawer-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 4px;
  background: var(--ed-surface);
  border: 0.5px solid var(--ed-border);
  border-radius: var(--r-sharp);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.66rem;
  color: var(--ed-muted-2);
  transition: all var(--t-fast);
}
.rh2-drawer-mode-btn:hover { border-color: var(--ed-ink); color: var(--ed-ink); }
.rh2-drawer-mode-btn.active {
  border-color: var(--ed-ink);
  background: var(--ed-gold-wash);
  color: var(--ed-ink);
  font-weight: 500;
}
.rh2-drawer-mode-icon { font-size: 1rem; line-height: 1; color: var(--ed-gold-deep); }

/* ── Mode: BAR (default) ── top bar + hamburger, drawer is modal ──
   Default behavior — already styled above. Nothing extra needed. */

/* ── Mode: BURGER ── hide top bar links, drawer is modal ── */
body[data-nav-mode="burger"] .rh2-nav-links { display: none; }

/* ── Mode: SIDE PANEL ── drawer permanent on left, content shifts right ── */
body[data-nav-mode="side-panel"] .rh2-drawer {
  transform: translateX(0);
  box-shadow: none;
  width: 240px;
}
body[data-nav-mode="side-panel"] .rh2-drawer-backdrop {
  display: none !important;
}
body[data-nav-mode="side-panel"] .rh2-drawer-close {
  /* No "close" button when the drawer is meant to stay open. */
  display: none;
}
body[data-nav-mode="side-panel"] .rh2-nav-hamburger {
  /* No hamburger when drawer is always visible. */
  display: none;
}
body[data-nav-mode="side-panel"] .rh2-nav-links {
  /* Top bar links also hidden — drawer is the nav. Top bar keeps brand
     + sign-in/out only. */
  display: none;
}
body[data-nav-mode="side-panel"] .rh2-nav,
body[data-nav-mode="side-panel"] .rh2-main,
body[data-nav-mode="side-panel"] main,
body[data-nav-mode="side-panel"] .splash,
body[data-nav-mode="side-panel"] section,
body[data-nav-mode="side-panel"] .status-foot,
body[data-nav-mode="side-panel"] footer {
  margin-left: 240px;
  transition: margin-left 0.25s ease-out;
}
@media (max-width: 720px) {
  /* On phones, side-panel mode degrades to burger mode — no room. */
  body[data-nav-mode="side-panel"] .rh2-drawer { transform: translateX(-100%); }
  body[data-nav-mode="side-panel"] .rh2-drawer.open { transform: translateX(0); }
  body[data-nav-mode="side-panel"] .rh2-drawer-backdrop { display: block !important; }
  body[data-nav-mode="side-panel"] .rh2-drawer-close { display: block; }
  body[data-nav-mode="side-panel"] .rh2-nav-hamburger { display: flex; }
  body[data-nav-mode="side-panel"] .rh2-nav,
  body[data-nav-mode="side-panel"] .rh2-main,
  body[data-nav-mode="side-panel"] main,
  body[data-nav-mode="side-panel"] .splash,
  body[data-nav-mode="side-panel"] section,
  body[data-nav-mode="side-panel"] .status-foot,
  body[data-nav-mode="side-panel"] footer {
    margin-left: 0;
  }
}

/* ── Mobile fallbacks ──
   On phones, the top nav links collapse — only hamburger + brand show.
   The drawer becomes the primary navigation surface. */
@media (max-width: 720px) {
  .rh2-main { padding: 1rem; }
  .rh2-title { font-size: 1.2rem; }
  .rh2-nav-links { display: none; }
  .rh2-nav-user { display: none; }
  .rh2-stats { grid-template-columns: 1fr 1fr; }
}
