/* eastaustralis.com - VFAB Online Hub.
   Design law: wrap-rl-eastaustralis (white-based, minimalist, compact, fuss-free),
   sitting atop the wrap-rl-website-design baseline floor. Base is black-and-white:
   white ground, near-black ink, grey for secondary. Colour appears ONLY where it
   carries meaning: the single eastaustralis brand accent (deep maroon), plus the
   two sanctioned functional colours (--danger for errors, --ok for success).
   One type scale (--text-*, <=6 sizes), one spacing scale (--space-*, 4px base).
   No gradients, no stacked shadows, system fonts, no external fetch.
   Responsive grid uses an auto-fit minmax variant (documented variant per the floor). */

:root {
  /* palette */
  --ground: #ffffff;
  --ink: #18181b;
  --muted: #6b7280;
  --line: #e6e6e9;

  /* eastaustralis brand accent (deep maroon) - interactive + brand only */
  --accent: #800000;          /* links, active, focus */
  --accent-strong: #5e0000;   /* hover / emphasis */
  --accent-solid: #800000;    /* maroon solid fill (brand mark, primary button) */
  --accent-tint: #f3e3e3;     /* faint maroon - focus ring / attention tint */
  --on-accent: #ffffff;       /* text on the maroon fill */

  /* functional semantic colours - the ONLY non-maroon colours, used for meaning
     (error / success) only; sanctioned by wrap-rl-eastaustralis. */
  --danger: #b42318;          /* errors, invalid input */
  --danger-tint: #fdecea;     /* invalid-input ring */
  --ok: #1a7f37;              /* success confirmations */

  /* type scale - <=6 steps; the hub (dashboard) tops out at --text-xl (24px) */
  --text-xs: 0.75rem;    /* 12px - table headers, badges, meta, eyebrow, captions */
  --text-sm: 0.875rem;   /* 14px - secondary text, table cells, buttons, labels */
  --text-base: 1rem;     /* 16px - body, inputs, lede */
  --text-lg: 1.25rem;    /* 20px - section titles, wordmark */
  --text-xl: 1.5rem;     /* 24px - page titles, dashboard numerics */

  /* spacing scale - 4px base */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  --measure: 40rem;                 /* capped reading measure for prose + auth cards */
  --app-measure: min(94vw, 80rem);  /* wide measure for data views */
  --space: var(--space-4);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--ground);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- global accessibility: one branded keyboard-focus ring + a skip link ----
   Inputs/selects/textareas keep their own box-shadow ring (higher specificity);
   this covers the previously-unstyled links, buttons, tabs, and icon buttons so
   keyboard focus is always visible and on-brand (maroon) rather than the UA blue. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--accent-solid); color: var(--on-accent);
  font-size: var(--text-sm); font-weight: 600; text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; top: 0; color: var(--on-accent); }

/* ---- top bar: one persistent, sticky, hairline-bottomed app bar on EVERY page. ---- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: var(--ground);                                   /* fallback */
  background: color-mix(in srgb, var(--ground) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
}
.topbar-inner {
  width: 100%;
  max-width: var(--app-measure);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) clamp(1rem, 4vw, 2rem);
  min-width: 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.brand-logo { width: 1.75rem; height: 1.75rem; display: block; object-fit: contain; flex: none; }
.brand-word { font-weight: 600; font-size: var(--text-sm); letter-spacing: 0.01em; white-space: nowrap; }
.brand-word em { color: var(--muted); font-style: normal; font-weight: 500; }

/* nav: links + an optional sign-out button, all sharing one quiet -> maroon style */
.topnav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  justify-content: flex-end;
}
.topnav a, .topnav-btn {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-decoration: none;
  cursor: pointer;
  padding: var(--space-2) var(--space-2);
  border-radius: 6px;
  white-space: nowrap;
}
.topnav a:hover, .topnav-btn:hover { color: var(--accent-strong); background: var(--accent-tint); }
.topnav a.is-active { color: var(--accent); font-weight: 600; background: var(--accent-tint); }
.topnav a.is-active:hover { color: var(--accent-strong); }

/* signed-in layout: functions left of the logo; account/utility icons on the right. */
.topbar-left { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.topbar-utils { display: flex; align-items: center; gap: var(--space-1); flex: none; }
.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
}
.iconbtn svg {
  width: 1.5rem; height: 1.5rem; display: block;   /* 24px, matches text line height */
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.iconbtn:hover { color: var(--accent-strong); background: var(--accent-tint); }
.iconbtn:active { filter: brightness(0.95); }
.iconbtn.is-active { color: var(--accent); background: var(--accent-tint); }

@media (max-width: 560px) {
  .brand-word { display: none; }          /* crest carries identity; save room for nav */
  .topbar-left { gap: var(--space-2); }
}

/* main */
.wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: clamp(2rem, 9vw, 5rem) clamp(1rem, 4vw, 2rem);
}
.hero { width: 100%; max-width: var(--measure); }

/* centered hero - the landing crest over white */
.hero-center {
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
}
.hero-logo { width: clamp(11rem, 34vw, 15rem); height: auto; display: block; }
.wordmark {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.hero-cta { margin: var(--space-1) 0 0; }
.cta {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--on-accent);
  background: var(--accent-solid);
  border: 1px solid var(--accent-solid);
  border-radius: 6px;
  padding: var(--space-2) var(--space-5);
}
.cta:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.cta:active { filter: brightness(0.95); }
.eyebrow {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
h1 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.lede { margin: 0; color: var(--muted); font-size: var(--text-base); max-width: 34rem; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

/* footer */
.foot {
  padding: var(--space-4) clamp(1rem, 4vw, 2rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-xs);
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.foot .sep { opacity: 0.5; }

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0f0f11;
    --ink: #f4f4f5;
    --muted: #9b9ba3;
    --line: #26262b;
    --accent: #e69a9a;        /* lightened maroon so links stay legible on dark */
    --accent-strong: #f2b3b3;
    --accent-solid: #800000;  /* brand tile + buttons stay true maroon */
    --accent-tint: #2a1414;
    --on-accent: #ffffff;
    --danger: #f0a39a;
    --danger-tint: #3a1714;
    --ok: #5bbf6a;
  }
}

/* ---- shared state / toast / nav-badge components (gap-closure Block A) ------
   One system reused by every list/detail/dashboard loader and nav item via
   EA.render (fetchJson/errorState/toast, hub.js navBadge). Tokens only, so dark
   mode is inherited from the :root remap above. */
.state { padding: var(--space-5) var(--space-4); text-align: center; color: var(--muted); }
.state-title { margin: 0 0 var(--space-1); font-weight: 600; color: var(--ink); font-size: var(--text-sm); }
.state-msg { margin: 0 0 var(--space-3); font-size: var(--text-sm); }
.state-error .state-title { color: var(--danger); }

.toast-region {
  position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 60;
  display: flex; flex-direction: column; gap: var(--space-2);
  max-width: min(92vw, 24rem);
}
.toast {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--ground); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); font-size: var(--text-sm);
}
.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-msg { flex: 1 1 auto; min-width: 0; }
.toast-link { flex: none; font-weight: 600; }
.toast-x {
  flex: none; border: 0; background: transparent; color: var(--muted);
  font-size: var(--text-lg); line-height: 1; cursor: pointer; padding: 0 var(--space-1);
}
.toast-x:hover { color: var(--ink); }

/* count pill on a nav item; space reserved so revealing it never shifts the bar */
.nav-badge {
  display: inline-grid; place-items: center;
  min-width: 1.05rem; height: 1.05rem; padding: 0 0.28rem; margin-left: 0.3rem;
  font-size: var(--text-xs); font-weight: 700; line-height: 1;
  color: var(--on-accent); background: var(--accent-solid); border-radius: 999px;
}
/* reserve the pill's box even when empty so a count change (0->N->0) never shifts the bar */
.nav-badge[hidden] { visibility: hidden; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: ea-toast-in 140ms ease-out; }
}
@keyframes ea-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- apex workspace chooser (eastaustralis.com/_apex) -----------------------
   Two sibling-workspace cards over the white ground. Reuses the card idiom and
   tokens only — no new colours, sizes, or fonts. The auto-fit minmax grid is the
   documented responsive variant. */
.chooser {
  list-style: none; margin: var(--space-6) 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-4); width: min(94vw, 38rem);
}
.chooser-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-2); min-height: 10rem; padding: var(--space-6) var(--space-4);
  border: 1px solid var(--line); border-radius: 10px; background: var(--ground);
  color: var(--ink); text-decoration: none;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.chooser-card:hover, .chooser-card:focus-visible { border-color: var(--accent); transform: translateY(-1px); }
.chooser-card img { height: 3.25rem; width: auto; max-width: 78%; object-fit: contain; }
.chooser-name { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; }
.chooser-sub { font-size: var(--text-sm); color: var(--muted); }

/* ---- VFAB horizontal wordmark (the "normal" logo) ----------------------------
   Used in the top bar and the landing hero; the square mark stays for square/social
   contexts (favicon, the /q letterhead). Both are monochrome and invert in dark mode. */
.brand-wordmark { height: 1.15rem; width: auto; display: block; object-fit: contain; flex: none; }
.hero-wordmark { width: clamp(11rem, 40vw, 18rem); height: auto; display: block; }

/* ---- brand marks in dark mode ------------------------------------------------
   The VFAB mark/wordmark and the VTAS logo are solid-monochrome marks, so on the
   dark ground they are inverted to stay visible. The full-colour East Australis
   crest opts out with .crest. Marks use object-fit:contain, so aspect is preserved. */
@media (prefers-color-scheme: dark) {
  .brand-logo:not(.crest), .hero-logo:not(.crest),
  .brand-wordmark, .hero-wordmark, .chooser-card img { filter: invert(1); }
}
