/* gsysd.com — single stylesheet.
   Semantic design tokens drive both themes; components never use raw hex.
   Light is the base; dark overrides via media query (System) and
   [data-theme] attributes set by js/theme.js (explicit user choice). */

:root {
  /* -- brand-neutral token palette -- */
  --bg: #ffffff;
  --bg-alt: #f4f6f8;
  --text: #1a2330;
  --text-muted: #4d5a6b;      /* 7.0:1 on --bg */
  --accent: #0b5cad;          /* links/buttons: 5.9:1 on white */
  --accent-contrast: #ffffff;
  --border: #d4dae2;
  --focus-ring: #0b5cad;
  --danger: #b3261e;      /* 6.5:1 on white */
  --max-width: 68rem;
}

/* Dark theme tokens — applied when (a) system prefers dark and the user
   hasn't overridden, or (b) the user explicitly chose dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10161e;
    --bg-alt: #1a2330;
    --text: #e8edf3;
    --text-muted: #a7b4c4;
    --accent: #6db3f2;
    --accent-contrast: #10161e;
    --border: #2c3a4d;
    --focus-ring: #6db3f2;
    --danger: #f2b8b5;
  }
}
:root[data-theme="dark"] {
  --bg: #10161e;
  --bg-alt: #1a2330;
  --text: #e8edf3;
  --text-muted: #a7b4c4;
  --accent: #6db3f2;
  --accent-contrast: #10161e;
  --border: #2c3a4d;
  --focus-ring: #6db3f2;
  --danger: #f2b8b5;
}

/* -- reset & base -- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; height: auto; }

/* Respect reduced motion globally */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* -- accessibility helpers -- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* -- layout -- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

/* -- header / nav (mobile-first) -- */
header.site {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  max-width: var(--max-width);
  margin: 0 auto;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  /* 44px touch target */
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
}
.brand img { flex: none; }
nav.primary ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}
nav.primary a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.75rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
}
nav.primary a:hover { background: var(--bg-alt); }
nav.primary a[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 6px;
}

/* -- appearance (theme) control: monochrome glyph buttons -- */
.theme-control {
  position: relative;
  width: 44px;
  height: 44px;
}
.theme-menu {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
}
.theme-btn {
  min-width: 44px;
  min-height: 44px;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: none;
}
/* collapsed: only the active choice shows */
.theme-btn[aria-pressed="true"] { display: inline-flex; align-items: center; justify-content: center; color: var(--accent); }
/* expanded on hover, keyboard focus, or tap-toggled .open */
.theme-control:hover .theme-menu,
.theme-control:focus-within .theme-menu,
.theme-control.open .theme-menu {
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  z-index: 20;
}
.theme-control:hover .theme-btn,
.theme-control:focus-within .theme-btn,
.theme-control.open .theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-btn:hover { color: var(--text); background: var(--bg-alt); }

/* -- main content -- */
main { padding: 2rem 0 3rem; flex: 1 0 auto; }
/* Home: distribute spare viewport height with intent — a smaller band
   above the hero (2 parts), a proportional hero↔cards gap, and a larger
   band below (3 parts), so the composition sits just high of center.
   Laptop heights collapse to normal flow. */
.main-center {
  display: flex;
}
.main-center .container {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
}
.main-center .container::before { content: ""; flex: 2 0 0; }
.main-center .container::after  { content: ""; flex: 3 0 0; }
.main-center .hero { margin-bottom: clamp(2.5rem, 9vh, 7rem); }
.main-center .card-grid { margin: 0; }

h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.4rem; margin: 2rem 0 0.75rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
.lede { font-size: 1.2rem; color: var(--text-muted); }

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 0;
  margin: 1.5rem 0;
  list-style: none;
}
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  background: var(--bg-alt);
}
.card h2, .card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.card p { margin: 0; color: var(--text-muted); }

/* Placeholder marker — remove class when real copy lands */
.placeholder { border-left: 4px solid var(--border); padding-left: 1rem; color: var(--text-muted); font-style: italic; }

/* -- article/press lists -- */
.pub-list { list-style: none; padding: 0; margin: 1rem 0; }
.pub-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.pub-list .date {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  margin-right: 0.75rem;
}

/* -- home hero -- */
.hero {
  display: grid;
  gap: 2rem;
  align-items: center;
  margin-bottom: 1rem;
}
.hero-img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}
@media (min-width: 768px) {
  .hero { grid-template-columns: 3fr 2fr; }
  }

/* -- restored archive articles -- */
.archive-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  border-left: 4px solid var(--border);
  padding-left: 1rem;
  margin-bottom: 1.5rem;
}
.article blockquote {
  margin: 1rem 0 1rem 1rem;
  padding-left: 1rem;
  border-left: 4px solid var(--border);
  color: var(--text-muted);
}
.article cite { display: block; margin-top: 0.5rem; font-size: 0.85rem; }
.article img { display: block; margin: 1rem auto; }

/* -- contact form -- */
#contact-form { max-width: 36rem; margin-top: 1.5rem; }
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.field input,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.field textarea { resize: vertical; }
.hint { font-size: 0.85rem; color: var(--text-muted); margin: 0.35rem 0 0; }
/* Honeypot: remove from visual + AT + tab order; bots parsing raw HTML still see it */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#cf-submit {
  min-height: 44px;
  padding: 0 1.5rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-contrast);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#cf-submit:disabled { opacity: 0.6; cursor: default; }
.cf-turnstile { margin-bottom: 1rem; }
.status-error { color: var(--text); font-weight: 600; border-left: 4px solid var(--danger); padding-left: 0.75rem; }
.status-ok { color: var(--text-muted); font-weight: 600; }

/* -- footer -- */
footer.site {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
footer.site .container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
footer.site a { color: var(--text-muted); }

/* -- breakpoints (min-width, mobile-first) -- */
@media (min-width: 480px) {
  h1 { font-size: 2.2rem; }
}
@media (min-width: 768px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  footer.site .container { flex-direction: row; justify-content: space-between; }
}
@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}
