/* ==========================================================================
   HKATA — Official Space Theme (assets/theme.css)
   Single source of truth for design tokens + reusable component classes.
   Linked from every page. Tailwind (via CDN) remains for utilities but
   colors are mapped to these CSS variables in the inline tailwind.config.
   ========================================================================== */

:root {
  /* SURFACES — deep institutional navy */
  --surface-900: #0A1224;
  --surface-800: #0F1A30;
  --surface-700: #16233F;
  --surface-600: #1E2E4D;

  /* BORDERS */
  --border:      rgba(255, 255, 255, 0.10);
  --border-soft: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* PRIMARY — confident azure */
  --primary-700: #1F4FB5;
  --primary-500: #2E6FE0;
  --primary-400: #4C8DF5;
  --primary-300: #8FB6FA;

  /* PRESTIGE — restrained gold (30 週年, awards, seals) */
  --gold-700: #9B7C33;
  --gold-500: #C7A24C;
  --gold-300: #E3C983;

  /* TEXT */
  --text-hi:   #EAF0FA;
  --text-body: #B7C2D4;
  --text-mute: #7C8AA3;

  /* GROUP ACCENTS — desaturated identifiers (1–3 px only) */
  --group-k: #3FA6A0;
  --group-p: #3B7BD1;
  --group-s: #6B63C4;

  /* Display font family (Latin) — adds IBM Plex Sans (free, OFL) as a more
     institutional fallback after Space Grotesk. Loaded in HTML head. */
  --font-display: 'Space Grotesk', 'IBM Plex Sans', 'Inter', 'Noto Sans TC', sans-serif;

  /* STATUS */
  --ok:         #24A148;
  --active:     #2E6FE0;
  --soon:       #6B7890;
  --milestone:  #C7A24C;

  /* SHADOWS — flat, no neon glow */
  --elev-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --elev-2: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 12px 32px rgba(0, 0, 0, 0.45);
  --focus-ring: 0 0 0 1.5px var(--primary-400);
}

/* --------------------------------------------------------------------------
   BASE
   -------------------------------------------------------------------------- */

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(46, 111, 224, 0.12), transparent 60%),
    radial-gradient(800px 500px at 90% 30%, rgba(199, 162, 76, 0.06), transparent 70%),
    var(--surface-900);
  color: var(--text-body);
  font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Chinese typography — let Noto Sans TC handle TC where available */
:lang(zh-HK), :lang(zh-Hant) {
  font-family: 'Noto Sans TC', 'Inter', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  word-break: break-word;
  line-height: 1.7;
}

/* Display — Latin display + ceremonial TC serif for anniversary H1 */
.font-display { font-family: var(--font-display); letter-spacing: -0.02em; }
.font-serif-tc { font-family: 'Noto Serif TC', 'Noto Sans TC', serif; letter-spacing: 0.01em; }

/* --------------------------------------------------------------------------
   LAYOUT TOKENS
   -------------------------------------------------------------------------- */

.container-x { max-width: 1200px; margin-inline: auto; padding-inline: 1.5rem; }
.section-y { padding-block: clamp(1.5rem, 2.5vw, 2.5rem); }
.eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.h1 { font-size: clamp(2rem, 4vw + 0.5rem, 3rem); line-height: 1.15; font-weight: 700; color: var(--text-hi); letter-spacing: -0.02em; }
.h2 { font-size: clamp(1.5rem, 2.5vw + 0.5rem, 2.25rem); line-height: 1.2; font-weight: 700; color: var(--text-hi); letter-spacing: -0.015em; }
.h3 { font-size: 1.25rem; line-height: 1.3; font-weight: 700; color: var(--text-hi); letter-spacing: -0.01em; }
.body-lg { font-size: 1.0625rem; line-height: 1.7; color: var(--text-body); }
.body { font-size: 0.9375rem; line-height: 1.65; color: var(--text-body); }
.caption { font-size: 0.8125rem; color: var(--text-mute); line-height: 1.55; }

/* --------------------------------------------------------------------------
   COMPONENT CLASSES
   -------------------------------------------------------------------------- */

/* SURFACES */
.surface { background: var(--surface-800); border: 1px solid var(--border); }
.surface-alt { background: var(--surface-900); border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.card {
  background: var(--surface-700);
  border: 1px solid var(--border);
  border-radius: 1rem;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--elev-1); }

/* GROUP CARDS — use a thin accent on the left edge */
.card-k { border-left: 3px solid var(--group-k); }
.card-p { border-left: 3px solid var(--group-p); }
.card-s { border-left: 3px solid var(--group-s); }

/* CHIPS */
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.7rem; font-weight: 600;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.chip-k { background: rgba(63, 166, 160, 0.08); border-color: rgba(63, 166, 160, 0.35); color: #7BD0C9; }
.chip-p { background: rgba(59, 123, 209, 0.08); border-color: rgba(59, 123, 209, 0.35); color: #8FB6FA; }
.chip-s { background: rgba(107, 99, 196, 0.08); border-color: rgba(107, 99, 196, 0.35); color: #A8A3E8; }
.chip-gold { background: rgba(199, 162, 76, 0.10); border-color: rgba(199, 162, 76, 0.40); color: var(--gold-300); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
  padding: 0.75rem 1.4rem;
  font-weight: 700; font-size: 0.9rem; letter-spacing: 0.04em;
  border-radius: 999px;
  transition: background-color 180ms ease, transform 180ms ease, border-color 180ms ease;
  cursor: pointer;
}
.btn-primary {
  background: var(--primary-500);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-400); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-500), var(--gold-700));
  color: #0A1224;
}
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--text-hi);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { border-color: var(--primary-400); color: var(--primary-300); }

/* LINK */
.link { color: var(--primary-300); text-decoration: none; transition: color 150ms; }
.link:hover { color: var(--text-hi); }

/* DIVIDER */
.divider-soft { height: 1px; background: var(--border-soft); border: 0; margin: 0; }

/* STATUS PILL */
.status { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.status-ok { color: var(--ok); background: rgba(62, 156, 116, 0.10); border: 1px solid rgba(62, 156, 116, 0.30); }
.status-active { color: var(--primary-300); background: rgba(46, 111, 224, 0.10); border: 1px solid rgba(46, 111, 224, 0.35); }
.status-soon { color: var(--soon); background: rgba(108, 120, 144, 0.10); border: 1px solid rgba(108, 120, 144, 0.30); }
.status-milestone { color: var(--gold-300); background: rgba(199, 162, 76, 0.10); border: 1px solid rgba(199, 162, 76, 0.35); }

/* RUBRIC DONUT */
.rubric-donut { width: 220px; height: 220px; transform: rotate(-90deg); }
.rubric-donut circle { fill: none; stroke-width: 18; }
.rubric-segment { transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1); }

/* HEADER UTILITY STRIP */
.util-strip {
  height: 32px;
  background: var(--surface-800);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-mute);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  display: flex; align-items: center;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-900); }
::-webkit-scrollbar-thumb { background: var(--surface-600); border-radius: 8px; border: 2px solid var(--surface-900); }
::-webkit-scrollbar-thumb:hover { background: var(--primary-500); }

.scrollbar-hide { scrollbar-width: none; -ms-overflow-style: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* FOCUS */
:focus-visible {
  outline: 2px solid var(--primary-400);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ACCESSIBILITY */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.sr-only-focusable:focus, .sr-only-focusable:focus-within {
  position: static; width: auto; height: auto; clip: auto; margin: 0; padding: 0.5rem 0.75rem;
  background: var(--primary-500); color: #fff; border-radius: 6px;
}

/* MOTION */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* TOAST */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--surface-700); color: var(--text-hi);
  border: 1px solid var(--border);
  padding: 0.7rem 1.1rem; border-radius: 999px;
  font-size: 0.85rem; letter-spacing: 0.02em;
  box-shadow: var(--elev-2);
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* T32: SUCCESS MODAL — centered acknowledgement replacing the bottom toast for the submission-confirmation UX */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 10, 22, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface-700);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem 1.75rem 1.75rem;
  width: min(440px, calc(100vw - 2rem));
  box-shadow: var(--elev-2);
  text-align: center;
  transform: translateY(0.75rem) scale(0.98);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}
.modal-backdrop.show .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal-icon {
  width: 56px; height: 56px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(46, 111, 224, 0.10);
  border: 2px solid var(--primary-500);
  color: var(--primary-300);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}
.modal h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
  color: var(--text-hi);
  letter-spacing: -0.01em;
}
.modal-appid {
  display: inline-block;
  font-family: var(--font-display);
  background: rgba(199, 162, 76, 0.10);
  border: 1px solid var(--gold-500);
  color: var(--gold-300);
  padding: 0.4rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  margin: 0.25rem 0 0.75rem;
}
.modal-body { font-size: 0.92rem; color: var(--text-body); line-height: 1.55; margin: 0 0 0.5rem; }
.modal-sub  { font-size: 0.78rem; color: var(--text-mute); margin: 0 0 1.25rem; line-height: 1.55; }
.modal-sub .accent { color: var(--gold-300); }
.modal-icon-warn {
  background: rgba(199, 162, 76, 0.10);
  border-color: var(--gold-500);
  color: var(--gold-300);
}
.modal-actions {
  display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap;
}
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { transition: none; }
}

/* NAV */
.nav-link {
  position: relative;
  color: var(--text-hi);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.5rem 0;
  transition: color 150ms;
}
.nav-link:hover { color: var(--text-hi); opacity: 0.8; }
.nav-link[aria-current="page"] { color: var(--text-hi); }
.nav-link[aria-current="page"]::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--primary-500); border-radius: 2px;
}

/* FORM */
.field {
  width: 100%;
  background: var(--surface-800);
  border: 1px solid var(--border);
  color: var(--text-hi);
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: border-color 150ms, background-color 150ms;
}
.field:focus { border-color: var(--primary-400); background: var(--surface-700); }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-hi); margin-bottom: 0.4rem; display: block; }
.field-help { font-size: 0.75rem; color: var(--text-mute); margin-top: 0.35rem; }

/* TABLE (pathway matrix on prospectus pages) */
.matrix-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.matrix-table th, .matrix-table td { padding: 0.75rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border-soft); }
.matrix-table th { font-weight: 600; color: var(--text-hi); background: var(--surface-800); font-size: 0.8rem; letter-spacing: 0.04em; }
.matrix-table tbody tr:hover { background: rgba(46, 111, 224, 0.04); }
.matrix-table .check { color: var(--group-k); font-weight: 700; }
.matrix-table .dash { color: var(--text-mute); }
