/* AutoEditz web — shared design tokens and primitives.
 *
 * Tokens are the canonical brand values, not new inventions:
 *   colors   AUTOCAST_DESIGN_SYSTEM.html :root  ==  AutoCastShared/DesignSystem/AutoCastColors.swift
 *   radii    4 badge / 6 button / 10 card / 16 modal
 *   spacing  4pt base scale
 *
 * The primary action is the wordmark gradient indigo -> cyan at 135deg.
 * Do not substitute a flat blue here; BrandPrimaryButtonStyle.swift calls that
 * out explicitly and the landing page previously drifted to #4A9FE8.
 *
 * Every page in public/ links this file. Do not re-declare tokens in a page.
 */

:root {
  /* brand */
  --indigo: #6366F1;
  --indigo-light: #818CF8;
  --cyan: #06B6D4;
  --cyan-light: #22D3EE;
  --orange: #F59E0B;
  --green: #22C55E;
  --red: #EF4444;
  --pink: #EC4899;

  /* surfaces */
  --bg: #08080D;
  --surface: #111118;
  --surface-2: #1A1A24;
  --surface-3: #24243A;
  --border: rgba(99, 102, 241, 0.16);
  --border-subtle: rgba(255, 255, 255, 0.07);

  /* text */
  --text-1: #EDEDF0;
  --text-2: #9494A8;
  --text-3: #5C5C72;

  /* radii */
  --r-badge: 4px;
  --r-btn: 6px;
  --r-card: 10px;
  --r-modal: 16px;

  /* spacing — 4pt base */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 16px;
  --s-lg: 20px;
  --s-xl: 24px;
  --s-2xl: 32px;
  --s-3xl: 48px;

  --brand-gradient: linear-gradient(135deg, var(--indigo), var(--cyan));
  --max: 1120px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Respect a reduced-motion preference for the smooth-scroll and transitions. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

a { color: inherit; }

/* Visible focus ring — keyboard users must be able to see where they are. */
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--indigo-light);
  outline-offset: 3px;
  border-radius: var(--r-btn);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--s-xs);
  padding: var(--s-xs) var(--s-md);
  background: var(--surface-2);
  border-radius: var(--r-btn);
  z-index: 10;
}
.skip-link:focus { left: var(--s-md); }

/* ---------------------------------------------------------------- layout */

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--s-xl); }

main { flex: 1; }

section { padding: var(--s-3xl) 0; }

.section-head { margin-bottom: var(--s-xl); }

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--indigo-light);
}

h1 {
  font-size: clamp(2.1rem, 5.4vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.06;
}

h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  margin-top: var(--s-xs);
}

h3 { font-size: 1.02rem; font-weight: 650; letter-spacing: -0.01em; }

p.lede { color: var(--text-2); max-width: 62ch; margin-top: var(--s-sm); }

.mono {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 0.86em;
}

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }

/* ------------------------------------------------------------------ nav */

.topbar { border-bottom: 1px solid var(--border-subtle); }

.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-md);
  padding-top: var(--s-md);
  padding-bottom: var(--s-md);
}

.brand { display: flex; align-items: center; gap: var(--s-sm); text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand span { font-size: 1.08rem; font-weight: 800; letter-spacing: -0.02em; }

.navlinks { display: flex; align-items: center; gap: var(--s-lg); }
.navlinks a { color: var(--text-2); text-decoration: none; font-size: 0.9rem; }
.navlinks a:hover { color: var(--text-1); }

@media (max-width: 640px) {
  .navlinks a.optional { display: none; }
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  padding: 12px 24px;
  min-height: 44px;
  border-radius: var(--r-btn);
  font-size: 0.95rem;
  font-weight: 650;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.88; }

.btn-primary { background: var(--brand-gradient); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text-1); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-subtle); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-sm); margin-top: var(--s-xl); }

/* ----------------------------------------------------------------- cards */

.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--s-lg);
}

.grid { display: grid; gap: var(--s-md); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 .featured { order: -1; }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-4 .featured { order: -1; }
}

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--r-badge);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip-shipped { background: rgba(34, 197, 94, 0.14); color: var(--green); }
.chip-partial { background: rgba(245, 158, 11, 0.14); color: var(--orange); }
.chip-planned { background: rgba(148, 148, 168, 0.12); color: var(--text-2); }
.chip-live { background: rgba(6, 182, 212, 0.14); color: var(--cyan-light); }
.chip-fail { background: rgba(239, 68, 68, 0.14); color: var(--red); }

/* ---------------------------------------------------------------- stats */

.stat .n {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat .k { margin-top: var(--s-xxs); font-size: 0.82rem; color: var(--text-2); }

/* ---------------------------------------------------------------- table */

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 var(--s-sm) var(--s-xs);
}
td {
  padding: var(--s-sm);
  border-top: 1px solid var(--border-subtle);
  vertical-align: top;
  color: var(--text-1);
}
td.k { color: var(--text-2); white-space: nowrap; }

.scroll-x { overflow-x: auto; }

/* --------------------------------------------------------------- notices */

.notice {
  border-radius: var(--r-card);
  padding: var(--s-md) var(--s-lg);
  font-size: 0.9rem;
  line-height: 1.55;
  border: 1px solid;
}
.notice-info { background: rgba(99, 102, 241, 0.08); border-color: rgba(99, 102, 241, 0.28); }
.notice-warn { background: rgba(245, 158, 11, 0.07); border-color: rgba(245, 158, 11, 0.28); }

/* ---------------------------------------------------------------- footer */

footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--s-xl) 0;
  color: var(--text-3);
  font-size: 0.84rem;
}
footer .wrap { display: flex; flex-wrap: wrap; gap: var(--s-sm) var(--s-md); justify-content: space-between; }
footer a { color: var(--text-2); text-decoration: none; }
footer a:hover { color: var(--text-1); }
footer nav { display: flex; flex-wrap: wrap; gap: var(--s-md); }

/* M5 — loading→rendered opacity transition for judge page data panels */
.kv, .stat .n, .dag > * {
  transition: opacity 0.15s ease;
}
.pending { opacity: 0.5; }

/* M1 — screenshot placeholder */
.screenshot-placeholder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: 0.88rem;
  margin-top: var(--s-xl);
}
