/* ============================================================
   Base styles and shared components for every page.
   Page-specific layout lives in web/css/<page>.css.
   Reference: design/*.html. Tokens: shared/tokens.css.
   ============================================================ */

/* ----- Reset and defaults ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-body); font-size: var(--fs-base); line-height: var(--lh-base);
  color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: var(--lh-snug); letter-spacing: var(--tracking-snug); font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, [role="button"] { min-height: 44px; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--shadow-focus); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--space-4); top: -80px; background: var(--fg); color: #fff; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); z-index: var(--z-toast); text-decoration: none; font-weight: 700; }
.skip-link:focus { top: var(--space-4); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
.brand-mark { font-family: var(--font-display); font-weight: 800; letter-spacing: var(--tracking-tight); color: var(--fg); }
/* Logo: TS mark image plus the name as live text in Sora ExtraBold (matches the wordmark, stays sharp). */
.brand { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--fg); font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg); letter-spacing: var(--tracking-tight); border-radius: var(--radius-sm); white-space: nowrap; }
.brand img { width: 40px; height: 32px; flex-shrink: 0; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; text-decoration: none; color: var(--fg);
  transition: background var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-spring);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow-primary); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--accent); }
.btn-quiet:hover { background: var(--accent-soft); }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--fs-xs); }
.btn-pill { border-radius: var(--radius-pill); padding-inline: var(--space-5); }
.btn[disabled] { cursor: not-allowed; color: var(--fg-muted); background: var(--surface-2); border-color: var(--border-strong); border-style: dashed; box-shadow: none; transform: none; }

/* ----- Fields ----- */
.field { display: grid; gap: var(--space-1); margin-bottom: var(--space-4); }
.field > label, .lbl { font-size: var(--fs-sm); font-weight: 700; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.req { font-size: var(--fs-xs); font-weight: 600; color: var(--fg-muted); }
.hint { font-size: var(--fs-xs); color: var(--fg-muted); }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input {
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface);
  padding: var(--space-2) var(--space-3); font-size: var(--fs-base); width: 100%;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .input:focus-visible { border-color: var(--accent); }
.field-error { font-size: var(--fs-sm); color: var(--late-fg); font-weight: 600; }
.count { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-muted); justify-self: end; }
.check { display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--fs-sm); padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 22px; accent-color: var(--accent); margin-top: 2px; flex-shrink: 0; }

/* Segmented control (aria-pressed buttons) */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 3px; gap: 3px; flex-wrap: wrap; width: fit-content; max-width: 100%; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 0 var(--space-4); font-size: var(--fs-sm); font-weight: 700; color: var(--fg-muted); cursor: pointer; min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }

/* Toggle chips (aria-pressed) and static chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { border: 1.5px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-pill); padding: 0 var(--space-4); font-weight: 700; font-size: var(--fs-sm); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip-static { font-size: var(--fs-xs); font-weight: 700; border-radius: var(--radius-pill); padding: 2px var(--space-3); background: var(--na-bg); color: var(--na-fg); border: 1px solid var(--border); }

/* ----- Status: symbol + word + colour (HANDOVER §11) ----- */
.tag { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--fs-xs); font-weight: 700; border-radius: var(--radius-pill); padding: 2px var(--space-3); min-height: 26px; }
.st-ok { background: var(--ok-bg); color: var(--ok-fg); }
.st-due { background: var(--due-bg); color: var(--due-fg); }
.st-late { background: var(--late-bg); color: var(--late-fg); }
.st-none { background: var(--surface); color: var(--late-fg); border: 1.5px dashed var(--late-fg); }
.st-na { background: var(--na-bg); color: var(--na-fg); }
.st-plain { background: var(--surface-2); color: var(--fg-muted); }

/* ----- Cards and panels ----- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-xs); }
.card h2, .card h3 { font-size: var(--fs-lg); margin-bottom: var(--space-1); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.meta { font-size: var(--fs-sm); color: var(--fg-muted); }
.kicker { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--fg-muted); }
.empty { padding: var(--space-7) var(--space-5); text-align: center; color: var(--fg-muted); }
.empty h2 { color: var(--fg); font-size: var(--fs-lg); margin-bottom: var(--space-2); }
.empty .btn { margin-top: var(--space-4); }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: var(--space-6); text-align: center; background: var(--surface-2); }
.dropzone strong { display: block; font-size: var(--fs-lg); font-family: var(--font-display); }

/* ----- Tooltips (HANDOVER §11): 26px trigger, 44px hit area, hover + focus + tap ----- */
.tipwrap { position: relative; display: inline-flex; vertical-align: middle; padding: 9px; margin: -9px; }
.tip-btn { width: 26px; height: 26px; min-height: 26px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--accent); font-weight: 800; font-style: italic; font-size: 0.8125rem; cursor: help; display: inline-grid; place-items: center; font-family: Georgia, serif; }
.tip-btn:hover, .tip-btn[aria-expanded="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.tip { position: absolute; z-index: var(--z-tooltip); left: 50%; top: calc(100% + 2px); transform: translateX(-50%) translateY(-4px); width: min(320px, 80vw); background: var(--tip-bg); color: var(--tip-fg); font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 500; font-style: normal; letter-spacing: 0; text-transform: none; text-align: left; line-height: var(--lh-base); padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); opacity: 0; visibility: hidden; transition: opacity var(--dur-fast), transform var(--dur-fast) var(--ease-out), visibility 0s linear var(--dur-fast); }
.tip::before { content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%) rotate(45deg); width: 12px; height: 12px; background: var(--tip-bg); }
.tip strong { display: block; font-family: var(--font-display); font-size: var(--fs-base); margin-bottom: var(--space-1); color: var(--tip-fg); }
.tip em { font-style: normal; color: var(--tip-em); }
.tipwrap:hover .tip, .tip-btn:focus-visible + .tip, .tip-btn[aria-expanded="true"] + .tip { opacity: 1; visibility: visible; transform: translateX(-50%); transition-delay: 0s; }
@media (max-width: 720px) {
  .tip { left: auto; right: -12px; transform: translateY(-4px); }
  .tip::before { left: auto; right: 18px; transform: rotate(45deg); }
  .tipwrap:hover .tip, .tip-btn:focus-visible + .tip, .tip-btn[aria-expanded="true"] + .tip { transform: none; }
}

/* ----- Overlays: side drawer and modal dialog ----- */
.overlay { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(6px); display: none; z-index: var(--z-modal); }
.overlay.open { display: block; }
.side-sheet { position: absolute; right: 0; top: 0; bottom: 0; width: min(440px, 100%); background: var(--surface); box-shadow: var(--shadow-xl); padding: var(--space-6); overflow-y: auto; animation: slide-in var(--dur-slow) var(--ease-out) both; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(620px, calc(100% - 2rem)); max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-xl); padding: var(--space-6); box-shadow: var(--shadow-xl); }
.close { position: absolute; top: var(--space-4); right: var(--space-4); width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); cursor: pointer; font-size: 1.1rem; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); font-size: var(--fs-sm); margin: var(--space-4) 0; }
.dl dt { color: var(--fg-muted); font-weight: 600; }
.dl dd { font-weight: 600; }

/* ----- Toast (aria-live region) ----- */
.toast { position: fixed; bottom: var(--space-5); left: 50%; transform: translate(-50%, 16px); background: var(--fg); color: #fff; padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); font-weight: 700; font-size: var(--fs-sm); box-shadow: var(--shadow-xl); opacity: 0; transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); z-index: var(--z-toast); pointer-events: none; max-width: calc(100% - 2rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ----- Page shell used by public and placeholder pages ----- */
.shell-top { background: rgb(247 247 242 / 0.92); backdrop-filter: blur(16px) saturate(160%); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: var(--z-sticky); }
.shell-top-inner { max-width: 1160px; margin: 0 auto; padding: var(--space-2) var(--space-4); display: flex; align-items: center; gap: var(--space-3); min-height: 60px; }
.shell-top-inner .right { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.shell { max-width: 880px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-8); }
.shell h1 { font-size: var(--fs-2xl); letter-spacing: var(--tracking-tight); }
.shell .lede { color: var(--fg-muted); margin-top: var(--space-2); max-width: 60ch; }
.shell-foot { max-width: 1160px; margin: 0 auto; padding: var(--space-5) var(--space-4); font-size: var(--fs-xs); color: var(--fg-muted); display: flex; gap: var(--space-3); flex-wrap: wrap; border-top: 1px solid var(--border); }
.shell-foot a { color: var(--fg-muted); }
.notice { background: var(--accent-soft); color: var(--accent-strong); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); font-size: var(--fs-sm); font-weight: 600; }

/* ----- Marketing accent (citron behind ink text only) ----- */
.hl { background: linear-gradient(transparent 58%, var(--citron) 58%, var(--citron) 92%, transparent 92%); color: inherit; padding: 0 0.08em; }
.tag-citron { background: var(--citron); color: var(--on-citron); }
