/* Base (light) + derived tokens. Only --surface, --text, --accent are user-customizable. */
:root {
  --surface: #ffffff;
  --text: #171717;
  --accent: #171717;
  --page: color-mix(in srgb, var(--surface) 94%, var(--text));
  --muted: color-mix(in srgb, var(--text) 62%, var(--surface));
  --line: color-mix(in srgb, var(--text) 14%, var(--surface));
  --line-strong: color-mix(in srgb, var(--text) 28%, var(--surface));
  --max-width: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #141414;
    --text: #ececec;
    --accent: #ececec;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --surface: #141414;
  --text: #ececec;
  --accent: #ececec;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  overflow-wrap: anywhere;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  margin-bottom: 0.2rem;
  font-size: 1.5rem;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  line-height: 1.15;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.35;
}

p {
  color: var(--muted);
}

.site-shell {
  width: min(100%, var(--max-width));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--surface);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--line);
}

.identity {
  margin-bottom: 2.25rem;
}

.identity p {
  margin: 0;
  font-size: 0.92rem;
}

.site-nav {
  display: grid;
  gap: 0.2rem;
}

.site-nav a {
  padding: 0.45rem 0;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 1px solid transparent;
  transition:
    color 140ms ease,
    border-color 140ms ease;
}

.site-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--line-strong);
}

.sidebar-copy {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.sidebar-copy p {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.main-content {
  min-width: 0;
}

.section {
  padding: 4rem clamp(1.5rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
}

.section-heading {
  margin-bottom: 2rem;
}

.intro-section {
  padding-top: 5.5rem;
}

.intro-text {
  max-width: 72ch;
  margin-bottom: 0;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.75;
  color: var(--text);
}

.line-list {
  border-top: 1px solid var(--line);
}

.line-item {
  display: grid;
  grid-template-columns: minmax(9rem, 0.35fr) minmax(0, 1fr);
  gap: 2rem;
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--line);
}

.line-item p {
  margin-bottom: 0;
}

.work-period {
  margin-bottom: 0.3rem !important;
  color: var(--text);
}

.text-link {
  display: inline-block;
  margin-top: 0.7rem;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

.text-link:hover {
  text-decoration-thickness: 2px;
}

.window-unused {
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.thought {
  padding: 1.5rem;
}

.thought + .thought {
  border-top: 1px solid var(--line);
}

.thought-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.thought-header time {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.thought p {
  margin-bottom: 0;
  max-width: 78ch;
  white-space: pre-line;
}

.social-list {
  border-top: 1px solid var(--line);
}

.social-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--line);
}

.social-item p {
  margin: 0.2rem 0 0;
}

.social-item .text-link {
  margin-top: 0;
  flex-shrink: 0;
}

.site-footer {
  width: min(100%, var(--max-width));
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: var(--page);
  border-top: 0;
}

.site-footer p {
  margin: 0;
  font-size: 0.85rem;
}

.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--page);
}

.error-content {
  width: min(100%, 600px);
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
}

.error-code {
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.error-content h1 {
  margin-bottom: 0.75rem;
}

.error-content p {
  max-width: 50ch;
}

@media (max-width: 820px) {
  .site-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 1.5rem;
  }

  .identity {
    margin-bottom: 1.5rem;
  }

  .site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
  }

  .sidebar-copy {
    margin-top: 1.5rem;
    padding-top: 1rem;
  }

  .section {
    padding: 3rem 1.5rem;
  }

  .intro-section {
    padding-top: 3.5rem;
  }
}

@media (max-width: 620px) {
  .line-item {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .thought-header,
  .social-item,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-footer {
    padding: 1.25rem 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .site-nav a {
    transition: none;
  }
}

/* ---------- additions ---------- */
.site-nav a:hover, .text-link:hover { color: var(--accent); }
.text-link { color: var(--accent); padding: 0.3rem 0; }
.section h2 { position: relative; padding-bottom: 0.6rem; }
.section h2::after { content: ""; position: absolute; left: 0; bottom: 0; width: 2.5rem; height: 3px; background: var(--accent); border-radius: 2px; }
.section-heading { margin-bottom: 2rem; }
.section h2 { margin-bottom: 1.6rem; }
.identity p { overflow-wrap: anywhere; }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin: 1.5rem 0 0; padding: 0; }
.tags li { padding: 0.3rem 0.8rem; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.92rem; }
.time-note { margin: 1.2rem 0 0; }
.time-note time { color: var(--accent); font-weight: 600; }
.group-title { margin: 2.2rem 0 0.8rem; color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; }
.lang-switch { margin: 1rem 0 0; font-size: 0.85rem; }
.lang-switch a { text-decoration: none; padding: 0.4rem 0.2rem; }
.lang-switch a[aria-current] { font-weight: 700; color: var(--accent); }

.button { display: inline-block; margin-top: 0.4rem; padding: 0.7rem 1.2rem; min-height: 44px; border-radius: 8px; background: var(--accent); color: var(--surface); text-decoration: none; font-weight: 600; }
.button:hover { opacity: 0.88; }

/* FlintSMP window */
.window { max-width: 560px; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.window-bar { display: flex; align-items: center; gap: 0.4rem; padding: 0.6rem 0.9rem; background: var(--page); border-bottom: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }
.window-bar i { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--line-strong); }
.window-bar span { margin-left: 0.6rem; }
.window-body { padding: 1.5rem; }
.window-body p { margin-bottom: 0.8rem; }
.window-hint { font-size: 0.9rem; }

/* Customizer */
.customizer-fab { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 20; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--accent); font-size: 1.3rem; cursor: pointer; }
.customizer-panel { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 58px); z-index: 21; width: min(340px, calc(100vw - 2rem)); max-height: 80vh; max-height: 80dvh; overflow-y: auto; padding: 1rem; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; }
.customizer-panel[hidden] { display: none; }
.customizer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.customizer-header h2 { font-size: 1.1rem; padding: 0; margin: 0; }
.customizer-header h2::after { display: none; }
.icon-button { width: 40px; height: 40px; border: 0; background: transparent; color: var(--text); font-size: 1.5rem; cursor: pointer; }
.cz-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; font-size: 0.95rem; }
.cz-row select { max-width: 60%; }
.cz-row select, .customizer-reset { min-height: 40px; padding: 0.3rem 0.6rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.cz-row input[type="color"] { width: 56px; height: 36px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: none; }
.customizer-reset { width: 100%; margin-top: 0.6rem; cursor: pointer; }
.cz-note { margin: 0.6rem 0 0; font-size: 0.8rem; }

/* Full mode only: transitions + reveal */
html:not(.lite) .reveal { opacity: 0; transform: translateY(12px); transition: opacity 500ms ease, transform 500ms ease; }
html:not(.lite) .reveal.in { opacity: 1; transform: none; }
html:not(.lite) .button, html:not(.lite) .tags li { transition: opacity 140ms ease, transform 140ms ease; }
html:not(.lite) .button:hover { transform: translateY(-1px); }

/* Lite mode (slow / metered / low-end devices): no motion, no effects */
html.lite { scroll-behavior: auto; }
html.lite *, html.lite *::before, html.lite *::after { transition: none !important; animation: none !important; }

@media (max-width: 820px) {
  .sidebar { padding: max(1.5rem, env(safe-area-inset-top)) 1.5rem 1.25rem; }
  .site-nav { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; gap: 0 1.2rem; -webkit-overflow-scrolling: touch; }
  .site-nav a { padding: 0.7rem 0; }
  .customizer-panel { right: 0.5rem; left: 0.5rem; width: auto; }
}
@media (max-width: 620px) {
  .section { padding: 2.5rem 1.25rem; }
  .cz-row select { max-width: 55%; }
}
@media (prefers-reduced-motion: reduce) {
  html:not(.lite) .reveal { opacity: 1; transform: none; transition: none; }
}
@media print { .customizer-fab, .customizer-panel { display: none; } }
