/* alexandru-savinov.github.io, v2
   A mashup: an Omarchy desk of tiles, an agterm tree for navigation,
   a Nix flake for structure, and a warm paper-and-serif voice.
   Four palettes; "Auto" follows prefers-color-scheme. No scripts. */

/* ---------- palettes ---------- */

/* Paper: the light default */
:root {
  color-scheme: light;
  --bg: #faf6ee; --bg2: #efe7d8; --border: #d6c9b2;
  --fg: #3a332b; --strong: #1f1a14; --muted: #695f54;
  --accent: #a4451d; --on-accent: #fffaf2;
  --key: #1f5f8b; --str: #48651c; --fn: #7b3fa0; --com: #75695c;
  --st-active: #1f6fb5; --st-blocked: #a85f08; --st-done: #3f7a2a;
  --wall:
    radial-gradient(70rem 40rem at 100% 0%, #e7a078 0%, transparent 62%),
    radial-gradient(60rem 45rem at 0% 100%, #7d3524 0%, transparent 65%),
    linear-gradient(160deg, #cf7447 0%, #b95a34 50%, #9a442b 100%);
  --cap-tokyo: none; --cap-gruvbox: none; --cap-latte: contents;
}

/* Tokyo Night: the dark default */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1a1b26; --bg2: #24283b; --border: #3b4261;
    --fg: #c0caf5; --strong: #e6eaff; --muted: #a9b1d6;
    --accent: #7aa2f7; --on-accent: #15161e;
    --key: #7dcfff; --str: #9ece6a; --fn: #bb9af7; --com: #8c95bd;
    --st-active: #7aa2f7; --st-blocked: #e0af68; --st-done: #9ece6a;
    --wall:
      radial-gradient(80rem 45rem at 100% 0%, #b4502f 0%, transparent 60%),
    radial-gradient(70rem 50rem at 0% 100%, #2a3f8f 0%, transparent 65%),
    linear-gradient(160deg, #3a1d5c 0%, #251a4a 45%, #6b2452 100%);
    --cap-tokyo: contents; --cap-gruvbox: none; --cap-latte: none;
  }
}

:root:has(#t-paper:checked) {
  color-scheme: light;
  --bg: #faf6ee; --bg2: #efe7d8; --border: #d6c9b2;
  --fg: #3a332b; --strong: #1f1a14; --muted: #695f54;
  --accent: #a4451d; --on-accent: #fffaf2;
  --key: #1f5f8b; --str: #48651c; --fn: #7b3fa0; --com: #75695c;
  --st-active: #1f6fb5; --st-blocked: #a85f08; --st-done: #3f7a2a;
  --wall:
    radial-gradient(70rem 40rem at 100% 0%, #e7a078 0%, transparent 62%),
    radial-gradient(60rem 45rem at 0% 100%, #7d3524 0%, transparent 65%),
    linear-gradient(160deg, #cf7447 0%, #b95a34 50%, #9a442b 100%);
  --cap-tokyo: none; --cap-gruvbox: none; --cap-latte: contents;
}

:root:has(#t-tokyo:checked) {
  color-scheme: dark;
  --bg: #1a1b26; --bg2: #24283b; --border: #3b4261;
  --fg: #c0caf5; --strong: #e6eaff; --muted: #a9b1d6;
  --accent: #7aa2f7; --on-accent: #15161e;
  --key: #7dcfff; --str: #9ece6a; --fn: #bb9af7; --com: #8c95bd;
  --st-active: #7aa2f7; --st-blocked: #e0af68; --st-done: #9ece6a;
  --wall:
    radial-gradient(80rem 45rem at 100% 0%, #b4502f 0%, transparent 60%),
    radial-gradient(70rem 50rem at 0% 100%, #2a3f8f 0%, transparent 65%),
    linear-gradient(160deg, #3a1d5c 0%, #251a4a 45%, #6b2452 100%);
  --cap-tokyo: contents; --cap-gruvbox: none; --cap-latte: none;
}

:root:has(#t-gruvbox:checked) {
  color-scheme: dark;
  --bg: #282828; --bg2: #3c3836; --border: #5a524c;
  --fg: #ebdbb2; --strong: #fbf1c7; --muted: #bdae93;
  --accent: #fabd2f; --on-accent: #1d2021;
  --key: #83a598; --str: #b8bb26; --fn: #d3869b; --com: #a89984;
  --st-active: #83a598; --st-blocked: #fe8019; --st-done: #b8bb26;
  --wall:
    radial-gradient(80rem 45rem at 100% 0%, #7c5a1e 0%, transparent 60%),
    radial-gradient(70rem 50rem at 0% 100%, #2f4a3a 0%, transparent 65%),
    linear-gradient(160deg, #3d3a1f 0%, #2a2f24 50%, #55361f 100%);
  --cap-tokyo: none; --cap-gruvbox: contents; --cap-latte: none;
}

:root:has(#t-latte:checked) {
  color-scheme: light;
  --bg: #eff1f5; --bg2: #e2e5ec; --border: #b4b8c6;
  --fg: #4c4f69; --strong: #33354d; --muted: #5c5f77;
  --accent: #1a5fe6; --on-accent: #ffffff;
  --key: #0b6e75; --str: #2b7a1b; --fn: #8839ef; --com: #666a82;
  --st-active: #1e66f5; --st-blocked: #a85f08; --st-done: #2b7a1b;
  --wall:
    radial-gradient(90rem 50rem at 100% 0%, #f5c2a8 0%, transparent 60%),
    radial-gradient(70rem 50rem at 0% 100%, #b7c8f7 0%, transparent 65%),
    linear-gradient(160deg, #f6d6dc 0%, #dfe3f3 55%, #cfe3ea 100%);
  --cap-tokyo: none; --cap-gruvbox: none; --cap-latte: contents;
}

/* ---------- base ---------- */

:root {
  --gap: 12px;
  --pad: clamp(1.1rem, 2vw, 1.75rem);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  --bar-h: 2.6rem;
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--bar-h) + var(--gap));
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--wall);
  color: var(--fg);
  font: 1.0625rem/1.6 var(--serif);
}

h1, h2, h3, p, ul, dl, dd, figure, pre, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

code, pre, .bar, .ph, .side, .ask, .tool, .meta, .line, .k, .todo, .button, .quiet, .inputs a, figcaption { font-family: var(--mono); }
code { font-size: 0.85em; }
p code { background: var(--bg2); padding: 0.1em 0.35em; border-radius: 4px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: var(--gap); top: -4rem; z-index: 10;
  padding: 0.5rem 0.9rem; background: var(--accent); color: var(--on-accent); font-family: var(--mono);
}
.skip:focus { top: var(--gap); }

.sym { color: var(--st-done); }

/* A marker for anything the owner still has to supply. */
.todo {
  display: inline;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  padding: 0.15em 0.45em;
  border: 1px dashed var(--st-blocked);
  border-radius: 4px;
  color: var(--strong);
  background: var(--bg2);
  font-size: 0.8em;
  overflow-wrap: anywhere;
}

/* ---------- status marks: shape and colour both carry the state ---------- */

.st { display: inline-block; flex: none; width: 0.6rem; height: 0.6rem; }
.st-active { border-radius: 50%; background: var(--st-active); animation: pulse 2.4s ease-in-out infinite; }
.st-done { border-radius: 50%; border: 2px solid var(--st-done); }
.st-idle { height: 2px; background: var(--muted); }
.st-blocked { background: var(--st-blocked); transform: rotate(45deg) scale(0.82); }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- the bar ---------- */

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.4rem 1.25rem;
  min-height: var(--bar-h);
  padding: 0.3rem max(var(--gap), calc((100vw - 1440px) / 2 + var(--gap)));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem; line-height: 1.4;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem; flex: none;
  color: var(--strong); text-decoration: none; font-weight: 600;
}
.mark rect { fill: none; stroke: var(--accent); stroke-width: 2; }
.store {
  flex: 1; min-width: 0; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--muted);
}
.store-hash { color: var(--com); }
.store-name { color: var(--strong); }

.themes { display: flex; flex: none; gap: 0.2rem; }
.th {
  position: relative;
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid transparent; border-radius: 6px;
  color: var(--muted); cursor: pointer;
}
.th input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.th i { width: 0.8rem; height: 0.8rem; border: 1px solid var(--border); border-radius: 2px; }
.th-auto i { background: linear-gradient(135deg, #faf6ee 50%, #1a1b26 50%); }
.th-paper i { background: linear-gradient(135deg, #faf6ee 50%, #b5532f 50%); }
.th-tokyo i { background: linear-gradient(135deg, #1a1b26 50%, #7aa2f7 50%); }
.th-gruvbox i { background: linear-gradient(135deg, #282828 50%, #fabd2f 50%); }
.th-latte i { background: linear-gradient(135deg, #eff1f5 50%, #1e66f5 50%); }
.th:hover { color: var(--strong); background: var(--bg2); }
.th:has(input:checked) { color: var(--strong); border-color: var(--accent); background: var(--bg2); }
.th:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Without :has() the page stays on Auto, so the switcher would be a dead control. */
@supports not selector(:has(*)) {
  .themes, .has-only { display: none; }
  .focus { border-color: var(--accent); }
}

/* ---------- the desk: a tree on the left, tiled panes on the right ---------- */

.desk {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  gap: var(--gap);
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--gap);
}
.panes {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  min-width: 0;
}

.tile {
  grid-column: span 12;
  min-width: 0;
  padding: var(--pad);
  background: var(--bg);
  border: 2px solid var(--border);
}
/* The accent border marks the focused pane: the hero by default, or whichever pane was jumped to. */
body:not(:has(.tile:target)) .focus, .tile:target { border-color: var(--accent); }

/* pane header: workspace / session, and its status */
.ph {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) var(--pad);
  padding: 0.45rem var(--pad);
  border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 0.78rem; line-height: 1.5;
}
.ph b { color: var(--strong); font-weight: 600; }
.ps { display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.pp { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

h1, h2, h3 { color: var(--strong); font-weight: 500; line-height: 1.1; letter-spacing: -0.015em; text-wrap: balance; }
h2 { font-size: clamp(1.7rem, 2.6vw, 2.3rem); }
h3 { font-size: 1.45rem; line-height: 1.2; }
.meta { color: var(--muted); font-size: 0.78rem; }

/* the tree */
.side {
  grid-column: auto;
  position: sticky; top: calc(var(--bar-h) + var(--gap));
  align-self: start;
  max-height: calc(100vh - var(--bar-h) - 2 * var(--gap));
  overflow: auto;
  padding: 1rem;
  font-size: 0.8125rem; line-height: 1.5;
}
.side .ph { margin: -1rem -1rem 1rem; padding: 0.45rem 1rem; }
.ws + .ws { margin-top: 1rem; }
.wsn { color: var(--strong); font-weight: 600; padding: 0.15rem 0.5rem; }
.wsn::before { content: "▾ "; color: var(--muted); }
.side li a {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.32rem 0.6rem 0.32rem 1.5rem;
  border-radius: 6px;
  color: var(--fg); text-decoration: none;
}
.side li a:hover { background: var(--bg2); color: var(--strong); }
body:has(#whoami:target) .side a[href="#whoami"],
body:has(#flake:target) .side a[href="#flake"],
body:has(#now:target) .side a[href="#now"],
body:has(#agterm-omarchy:target) .side a[href="#agterm-omarchy"],
body:has(#spike-mind:target) .side a[href="#spike-mind"],
body:has(#sancta:target) .side a[href="#sancta"],
body:has(#slot:target) .side a[href="#slot"],
body:has(#links:target) .side a[href="#links"],
body:has(#lock:target) .side a[href="#lock"],
body:not(:has(.tile:target)) .side a[href="#whoami"] { background: var(--bg2); color: var(--strong); }

.legend {
  display: grid; gap: 0.35rem;
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.75rem;
}
.legend div { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.5rem; padding: 0 0.5rem; }
.legend dt { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--fg); }
.legend-lock { display: none; font-family: var(--mono); }

/* hero: a question, one tool call, a calm answer */
.hero { grid-column: span 7; display: flex; flex-direction: column; }
.ask { color: var(--muted); font-size: 0.9rem; margin-top: auto; }
.tool {
  display: inline-flex; align-items: center; gap: 0.6rem; align-self: flex-start;
  margin-top: 0.6rem; padding: 0.2rem 0.7rem 0.2rem 0.6rem;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: 0.78rem;
}
.tool-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--st-done); }
h1 {
  margin-top: 1.5rem;
  font-size: clamp(2.7rem, 4.9vw, 4.4rem);
  font-weight: 500; letter-spacing: -0.03em; line-height: 1;
}
.lead { margin-top: 1.1rem; font-size: 1.25rem; }
.sub { margin-top: 0.7rem; max-width: 33rem; font-size: 1.2rem; line-height: 1.5; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; margin-top: 1.6rem; font-size: 0.875rem; }
.hero .actions { margin-bottom: auto; }
.button {
  display: inline-block; padding: 0.55rem 1rem; border-radius: 6px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 650; text-decoration: none;
}
.button:hover { filter: brightness(1.08); }
.quiet { font-weight: 550; }

/* flake.nix */
.flake { grid-column: span 5; }
.nix {
  font-size: 0.8rem; line-height: 1.6; color: var(--fg);
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2;
}
.nix code { font-size: inherit; }
.nix .c { color: var(--com); font-style: italic; }
.nix .k { color: var(--key); }
.nix .s { color: var(--str); }
.nix .f { color: var(--fn); }

/* featured project */
.feature-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--pad); align-items: center; }
.feature-text > p + p { margin-top: 0.85rem; }
.feature-text h2 { margin-bottom: 1rem; }
.feature-text .meta { margin-top: 1.4rem; }
.feature img { display: block; width: 100%; height: auto; border: 1px solid var(--border); background: var(--bg2); }
figcaption { margin-top: 0.6rem; color: var(--muted); font-size: 0.75rem; }
.cap-tokyo { display: var(--cap-tokyo); }
.cap-gruvbox { display: var(--cap-gruvbox); }
.cap-latte { display: var(--cap-latte); }

/* project cards */
.cards { grid-column: span 12; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.cards > .tile { grid-column: auto; }
.cards > .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.card { display: flex; flex-direction: column; gap: 0.75rem; }
.card .ph { margin-bottom: calc(var(--pad) - 0.75rem); }
.card h3 a { color: var(--strong); text-decoration: none; }
.card h3 a:hover { color: var(--accent); text-decoration: underline; }
.card:hover, .card:focus-within { border-color: var(--accent); }
.line {
  margin-top: auto; padding: 0.55rem 0.75rem; border-radius: 6px;
  background: var(--bg2); color: var(--fg);
  font-size: 0.78rem; line-height: 1.5; overflow-wrap: anywhere;
}
.card > .meta:last-child { margin-top: auto; }
.card > .line + .meta { margin-top: 0; }
.slot { border-style: dashed; }

.also {
  grid-column: span 12;
  padding: 0.6rem var(--pad);
  background: var(--bg); border: 2px solid var(--border);
  color: var(--muted); font-size: 1rem;
}

/* now + elsewhere */
.now { grid-column: span 7; }
.elsewhere { grid-column: span 5; }
.now h2, .elsewhere h2 { margin-bottom: 1rem; }
.now ul { display: grid; gap: 0.6rem; margin-bottom: 1.25rem; }
.now li { padding-left: 1.4rem; position: relative; }
.now li::before { content: "›"; position: absolute; left: 0.1rem; color: var(--st-done); font-family: var(--mono); }
.links { display: grid; gap: 0.5rem; }
.links li { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: 0.5rem; align-items: baseline; }
.k { color: var(--key); font-size: 0.8125rem; }

/* flake.lock: credits */
.inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem var(--pad); }
.inputs li { display: grid; gap: 0.25rem; align-content: start; font-size: 0.95rem; line-height: 1.45; }
.inputs a { font-size: 0.875rem; font-weight: 600; }
.fine { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; }

/* ---------- motion ---------- */

.bar, .tile, .also, .th, .button, .line, .todo, .side li a, .feature img {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .st-active { animation: none; }
  .bar, .tile, .also, .th, .button, .line, .todo, .side li a, .feature img { transition: none; }
}

/* ---------- narrower screens ---------- */

@media (max-width: 1180px) {
  .hero, .flake { grid-column: span 12; }
  .ask { margin-top: 0; }
  .feature-grid { grid-template-columns: minmax(0, 1fr); }
  .feature figure { order: -1; }
  .inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .store { display: none; }
  .brand { margin-right: auto; }
  .bar { flex-wrap: wrap; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; padding: 0.6rem 0.75rem; }
  .side .ph, .legend-side { display: none; }
  .legend-lock { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 1.25rem; padding-top: 1rem; }
  .ws { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
  .ws + .ws { margin-top: 0.4rem; }
  .ws ul { display: contents; }
  .wsn { padding: 0.3rem 0.4rem 0.3rem 0; }
  .side li a { padding: 0.3rem 0.6rem; border: 1px solid var(--border); gap: 0.5rem; }
  .legend div { padding: 0; }
}

@media (max-width: 640px) {
  :root { --gap: 8px; }
  .bar { position: static; }
  .th { padding: 0.5rem; }
  .th span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .th i { width: 1rem; height: 1rem; }
  .now, .elsewhere { grid-column: span 12; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .inputs { grid-template-columns: minmax(0, 1fr); }
  html { scroll-padding-top: var(--gap); }
}

@media print {
  body { background: none; }
  .themes, .skip, .side { display: none; }
  .desk { display: block; }
}
