/* ==========================================================================
   theme.css — shared design system for yukema.github.io
   Loaded first on every page. Everything else consumes these tokens.

   Light is the default; dark kicks in via html[data-theme="dark"], which
   assets/js/theme.js sets from localStorage or the OS preference.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens — light (default)
   -------------------------------------------------------------------------- */
:root {
  /* surfaces */
  --bg:            #fafaf8;   /* page background, warm off-white */
  --bg-elev:       #ffffff;   /* cards, panels */
  --bg-subtle:     #f3f3f0;   /* code blocks, inset areas */
  --bg-hover:      #f0f0ec;

  /* text */
  --text:          #18181b;
  --text-muted:    #5c636e;
  --text-dim:      #8b919c;

  /* lines */
  --border:        #e4e6e3;
  --border-strong: #d2d5d0;

  /* accent — MPI green */
  --accent:        #006C66;
  --accent-hover:  #00514c;
  --accent-soft:   rgba(0, 108, 102, 0.08);
  --accent-text:   #ffffff;   /* text on top of a filled accent */

  /* shadows (barely there in light mode) */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 16px -4px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, 0.18);

  /* syntax / inline code */
  --code-text:     #b5277d;

  /* typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* metrics */
  --width-content: 820px;     /* prose: ~95 characters per line */
  --width-wide:    1180px;    /* home rail+content, gallery, grids */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --nav-h:     58px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* TypeIt cursor picks this up */
  --ti-cursor-color: var(--accent);

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2. Design tokens — dark
   MPI green is too dark to read on near-black, so dark mode shifts the
   accent to a teal of the same family.
   -------------------------------------------------------------------------- */
html[data-theme="dark"] {
  --bg:            #0d1117;
  --bg-elev:       #161b22;
  --bg-subtle:     #1b2029;
  --bg-hover:      #20262f;

  --text:          #e6edf3;
  --text-muted:    #9aa5b1;
  --text-dim:      #6e7681;

  --border:        #2a3038;
  --border-strong: #3d444d;

  --accent:        #2dd4bf;
  --accent-hover:  #5eead4;
  --accent-soft:   rgba(45, 212, 191, 0.12);
  --accent-text:   #04201d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.65);

  --code-text:     #f0a8d0;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   3. Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.18s var(--ease);
}
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: var(--accent-soft); }

/* headings: tight, technical */
h1, h2, h3, h4 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

code, kbd, pre, samp { font-family: var(--font-mono); }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* --------------------------------------------------------------------------
   4. Shared layout shells
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--width-content);
  margin: 0 auto;
  padding: 0 24px;
}
.wrap--wide { max-width: var(--width-wide); }

.page-body {
  padding: 54px 0 90px;
}

/* sticky rail + content, used by the front page */
.shell {
  width: 100%;
  max-width: var(--width-wide);
  margin: 0 auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.shell__main { min-width: 0; }

.rail {
  position: sticky;
  top: calc(var(--nav-h) + 30px);
  max-height: calc(100vh - var(--nav-h) - 60px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.rail::-webkit-scrollbar { width: 6px; }
.rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* below 980px the rail stops being a column and sits above the content */
@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 34px;
    max-width: var(--width-content);
    padding: 0 24px;
  }
  .rail {
    position: static;
    max-height: none;
    overflow: visible;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border);
  }
}

/* --------------------------------------------------------------------------
   5. Top navigation (shared across every page)
   -------------------------------------------------------------------------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-nav__inner {
  height: 100%;
  max-width: var(--width-wide);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* monospace wordmark, terminal flavour */
.site-nav__brand {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.site-nav__brand:hover { color: var(--text); }
.site-nav__brand span { color: var(--accent); }

.site-nav__links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav__links a {
  font-size: 0.86rem;
  color: var(--text-muted);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  transition: color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.site-nav__links a:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.site-nav__links a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

/* theme switch */
.theme-toggle {
  margin-left: 6px;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.18s var(--ease);
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
/* show the icon for the mode you'd switch *to* */
.theme-toggle .icon-dark  { display: none; }
html[data-theme="dark"] .theme-toggle .icon-dark  { display: block; }
html[data-theme="dark"] .theme-toggle .icon-light { display: none; }

@media (max-width: 560px) {
  .site-nav__links a { padding: 6px 8px; font-size: 0.8rem; }
  .site-nav__brand  { font-size: 0.78rem; }
}

/* --------------------------------------------------------------------------
   6. Shared components
   -------------------------------------------------------------------------- */

/* section with a monospace kicker label */
.section { margin-bottom: 52px; }

.section__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.section__label::before { content: "// "; opacity: 0.45; }

.section > h2 {
  font-size: 1.32rem;
  margin-bottom: 20px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
}

/* card */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 19px 21px;
  margin-bottom: 14px;
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease),
              transform 0.22s var(--ease);
}
.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card h3 {
  font-size: 1.04rem;
  font-weight: 650;
  line-height: 1.4;
  margin-bottom: 7px;
}
.card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 13px;
}

/* badges */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  background: var(--accent);
  color: var(--accent-text);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 8px;
  vertical-align: middle;
}
.badge.badge-alt {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.card-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 0;
}
.card-links a {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  margin-right: 14px;
}
.card-links a:hover { text-decoration: underline; }

/* footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 30px 0 40px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}
.site-footer__inner {
  max-width: var(--width-wide);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer__spacer { margin-left: auto; }

/* visitor map widget, now living in the footer */
.visitor-map {
  max-width: 100%;
  overflow: hidden;
  line-height: 0;
}
.visitor-map canvas { max-width: 100% !important; height: auto !important; }

/* --------------------------------------------------------------------------
   7. Prose defaults (blog posts, wiki notes, note pages)
   -------------------------------------------------------------------------- */
.prose { color: var(--text); font-size: 1.0rem; line-height: 1.75; }

.prose > * + * { margin-top: 1.1em; }

.prose h2 {
  font-size: 1.42rem;
  margin-top: 2.1em;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}
.prose h3 { font-size: 1.14rem; margin-top: 1.8em; }

.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.4em; }

.prose a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

.prose code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--code-text);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.875em;
}

.prose pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
}
.prose pre code { background: none; border: 0; color: var(--text); padding: 0; font-size: inherit; }

/* Code blocks and diagrams carry wide content, so once there is room let
   them bleed past the prose measure instead of scrolling inside it. */
@media (min-width: 920px) {
  .prose pre,
  .prose .mermaid,
  .prose table {
    width: calc(100% + 72px);
    margin-left: -36px;
  }
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 13px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}
.prose blockquote > * + * { margin-top: 0.8em; }

.prose img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 1.6em auto;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.prose th { background: var(--bg-subtle); font-weight: 650; }

/* mermaid diagrams sit on the page background, not a white box */
.prose .mermaid { margin: 1.6em 0; text-align: center; }
.prose .mermaid svg { margin: 0 auto; }

/* --------------------------------------------------------------------------
   8. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
