/* Reset, app shell, layout, motion utilities. Tokens live in tokens.css. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* foundit brand board: ink #231815, light #EDEDED, orange #EA601E */
:root {
  --brand-ink: #231815;
  --brand-accent: #ea601e;
}
:root[data-theme='dark'] {
  --brand-ink: #ededed;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
table { border-collapse: collapse; width: 100%; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
/* The router focuses #outlet after each navigation for screen readers; it is not a control, so no ring. */
#outlet:focus-visible { outline: none; border-radius: 0; }

::selection { background: var(--primary-200); color: var(--ink); }

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.i { flex: none; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Shell ---------- */
.app { min-height: 100dvh; }
.main { min-width: 0; padding-bottom: 40px; }
.site-header { height: calc(var(--header-h) + var(--safe-t)); padding: var(--safe-t) 32px 0; display: flex; gap: 32px; align-items: center; background: var(--surface); border-bottom: 1px solid var(--divider); position: sticky; top: 0; z-index: 500; }
.brand { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.brand .brand-lockup { width: auto; }
.campus-label { padding-left: 18px; border-left: 1px solid var(--divider-strong); color: var(--text-2); font-size: 14px; white-space: nowrap; }
.desktop-nav { display: flex; align-self: stretch; gap: 8px; margin-left: auto; }
.nav-item { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 0 20px; color: var(--text-2); position: relative; font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; }
.nav-item[hidden] { display: none; }
.nav-item:hover { color: var(--text); background: var(--surface-soft); }
.nav-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.nav-count { background: var(--primary); color: var(--on-primary); font: 11px var(--font-num); min-width: 18px; padding: 2px 4px; border-radius: 10px; text-align: center; }
.header-help { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.header-help:hover { text-decoration: underline; }
.bottom-nav { display: none; }
.context-bar { max-width: var(--page-max); margin: auto; padding: 16px 24px 0; display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-2); }
.context-bar > [data-title] { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.context-bar > [data-actions] { margin-left: auto; }
.back-link { display: inline-flex; align-items: center; min-height: 36px; gap: 4px; flex: none; }
.back-link:hover { color: var(--primary); }
.page { width: 100%; max-width: var(--page-max); margin: 0 auto; padding: 0 24px; }
.page.narrow { max-width: 760px; }
.page.wide { max-width: 1320px; }
.view { min-width: 0; }
.skip-link { position: fixed; top: -80px; left: 12px; z-index: 2000; background: var(--surface); padding: 12px; border: 2px solid var(--primary); }
.skip-link:focus { top: 12px; }
@media (max-width: 767px) {
  :root { --header-h: 56px; }
  .site-header { padding-left: 16px; padding-right: 16px; gap: 16px; }
  .header-help { margin-left: auto; }
  .desktop-nav { display: none; }
  .brand { gap: 12px; }
  .campus-label { padding-left: 12px; font-size: 13px; }
  .main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
  .bottom-nav { position: fixed; inset: auto 0 0; z-index: 500; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border-top: 1px solid var(--divider); background: var(--surface); }
  .nav-item { flex-direction: column; gap: 3px; font-size: 12px; padding: 6px 8px; border-bottom: 0; border-top: 2px solid transparent; }
  .nav-item.active { border-top-color: var(--primary); }
  .nav-count { position: absolute; top: 5px; left: calc(50% + 10px); }
  .page { padding: 0 16px; }
  .context-bar { padding: 8px 16px 0; }
}

/* ---------- Layout helpers ---------- */
.stack { display: grid; gap: 12px; }
.stack-lg { display: grid; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.section-head .more { font-size: 13px; font-weight: 600; color: var(--primary); display: inline-flex; align-items: center; gap: 2px; }
.h-scroll {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; padding: 4px 16px 14px;
  margin: 0 -16px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll > * { scroll-snap-align: start; flex: none; }
@media (min-width: 640px) { .h-scroll { margin: 0 -28px; padding: 4px 28px 14px; } }
@media (min-width: 1024px) { .h-scroll { margin: 0 -32px; padding: 4px 32px 14px; } }

.two-col { display: grid; gap: 20px; }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); align-items: start; } .two-col.even { grid-template-columns: 1fr 1fr; } }
.sticky-col { position: sticky; top: 24px; }

/* ---------- Motion ---------- */
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes view-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes grow-bar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes grow-w { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes fresh-ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fresh) 45%, transparent); } 100% { box-shadow: 0 0 0 6px transparent; } }
@keyframes float-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes shake-x { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
@keyframes confetti-fall { 0% { transform: translate3d(0, -20px, 0) rotate(0); opacity: 1; } 100% { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 540deg)); opacity: 0.9; } }
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes marker-drop { 0% { transform: translateY(-26px) scale(0.6); opacity: 0; } 60% { transform: translateY(2px) scale(1.05); opacity: 1; } 100% { transform: none; } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* Staggered entrance: set --i on children (ui.stagger() does this). */
.stagger > * { animation: none; }

/* Scroll reveal (IntersectionObserver adds .in) */
.reveal { opacity: 1; transform: none; }
.reveal.in { opacity: 1; transform: none; }

.skeleton {
  background: linear-gradient(100deg, var(--surface-soft) 30%, var(--surface-sunk) 50%, var(--surface-soft) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--r-sm);
}

.ripple-host { position: relative; overflow: hidden; isolation: isolate; }
.ripple-dot {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: -1;
  background: currentColor; opacity: 0.18; transform: scale(0); animation: ripple 560ms var(--ease) forwards;
}

@media (hover: hover) {
  .lift { transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease); }
  .lift:hover { border-color: var(--divider-strong); }
}
.press { transition: transform var(--t-fast) var(--ease-spring); }
.press:active { background: var(--surface-soft); }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti-layer i { position: absolute; top: 0; width: 8px; height: 14px; border-radius: 2px; animation: confetti-fall var(--dur, 1800ms) cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .confetti-layer { display: none; }
  #outlet[aria-busy="true"]::before { background: var(--primary); background-size: 100% 100%; opacity: 0.6; }
}

.route-loading { padding: 32px; color: var(--text-2); font-size: 14px; }
/* 換頁時頁面還在等資料：頂端出現一條跑動的細線，表示點擊有收到。延遲 150ms 才出現，快的頁面不會閃。 */
#outlet[aria-busy="true"]::before {
  content: ""; position: fixed; top: var(--safe-t); left: 0; right: 0; height: 3px; z-index: 600; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--primary), transparent) no-repeat; background-size: 40% 100%;
  animation: route-wait 0s linear 150ms both, route-run 1.1s ease-in-out 150ms infinite;
}
@keyframes route-wait { from { opacity: 0; } to { opacity: 1; } }
@keyframes route-run { from { background-position: -60% 0; } to { background-position: 160% 0; } }
