/* ================================================================
   lavops terminal portfolio — styles
   Themes are just custom properties on :root[data-theme].
   Add one by copying a block and renaming it (then list it in
   THEMES in terminal.js).
   ================================================================ */

/* ---------- themes ---------- */

:root,
:root[data-theme="green"] {
  --page-bg: #030605;
  --term-bg: #0a120d;
  --bar-bg:  #0d1811;
  --edge:    #1e3826;
  --fg:      #9fefb4;
  --bright:  #e9ffee;
  --dim:     #56815f;
  --ok:      #61ff8e;
  --warn:    #ffd479;
  --err:     #ff7b72;
  --link:    #c9ffd6;
  --foot:    #45604d;
  --glow:    0 0 7px rgba(120, 255, 160, 0.22);
  --shadow:  0 18px 70px rgba(0, 0, 0, 0.75);
  --scanline: 1;
}

:root[data-theme="amber"] {
  --page-bg: #060402;
  --term-bg: #150e05;
  --bar-bg:  #1b1307;
  --edge:    #3d2d12;
  --fg:      #ffc46e;
  --bright:  #ffeccb;
  --dim:     #8f6c3c;
  --ok:      #ffd479;
  --warn:    #ffb340;
  --err:     #ff7b72;
  --link:    #ffe3ad;
  --foot:    #6f5732;
  --glow:    0 0 7px rgba(255, 190, 100, 0.22);
  --shadow:  0 18px 70px rgba(0, 0, 0, 0.75);
  --scanline: 1;
}

:root[data-theme="paper"] {
  --page-bg: #d8d3c4;
  --term-bg: #f6f3ea;
  --bar-bg:  #eae6d9;
  --edge:    #b5afa0;
  --fg:      #34332b;
  --bright:  #11100c;
  --dim:     #7e7867;
  --ok:      #1c7c3c;
  --warn:    #9a6b00;
  --err:     #b3261e;
  --link:    #11100c;
  --foot:    #6d675a;
  --glow:    none;
  --shadow:  0 14px 40px rgba(60, 55, 40, 0.28);
  --scanline: 0;
}

/* the editor themes: no CRT cosplay, they're from the flat era */
:root[data-theme="dracula"] {
  --page-bg: #191a21;
  --term-bg: #282a36;
  --bar-bg:  #21222c;
  --edge:    #44475a;
  --fg:      #f8f8f2;
  --bright:  #ffffff;
  --dim:     #6272a4;
  --ok:      #50fa7b;
  --warn:    #ffb86c;
  --err:     #ff5555;
  --link:    #8be9fd;
  --foot:    #6272a4;
  --glow:    none;
  --shadow:  0 18px 70px rgba(0, 0, 0, 0.6);
  --scanline: 0.25;
}

:root[data-theme="nord"] {
  --page-bg: #242933;
  --term-bg: #2e3440;
  --bar-bg:  #3b4252;
  --edge:    #434c5e;
  --fg:      #d8dee9;
  --bright:  #eceff4;
  --dim:     #7b88a1;
  --ok:      #a3be8c;
  --warn:    #ebcb8b;
  --err:     #bf616a;
  --link:    #88c0d0;
  --foot:    #7b88a1;
  --glow:    none;
  --shadow:  0 18px 70px rgba(0, 0, 0, 0.55);
  --scanline: 0.25;
}

:root[data-theme="gruvbox"] {
  --page-bg: #1d2021;
  --term-bg: #282828;
  --bar-bg:  #32302f;
  --edge:    #504945;
  --fg:      #ebdbb2;
  --bright:  #fbf1c7;
  --dim:     #928374;
  --ok:      #b8bb26;
  --warn:    #fabd2f;
  --err:     #fb4934;
  --link:    #83a598;
  --foot:    #928374;
  --glow:    none;
  --shadow:  0 18px 70px rgba(0, 0, 0, 0.6);
  --scanline: 0.25;
}

:root[data-theme="solarized"] {
  --page-bg: #00212b;
  --term-bg: #002b36;
  --bar-bg:  #073642;
  --edge:    #0f4d5c;
  --fg:      #93a1a1;
  --bright:  #fdf6e3;
  --dim:     #586e75;
  --ok:      #859900;
  --warn:    #b58900;
  --err:     #dc322f;
  --link:    #2aa198;
  --foot:    #586e75;
  --glow:    none;
  --shadow:  0 18px 70px rgba(0, 0, 0, 0.55);
  --scanline: 0.25;
}

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

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 20px 16px 14px;
  background: var(--page-bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Mono",
               "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

::selection { background: var(--fg); color: var(--term-bg); }

/* ---------- terminal window ---------- */

.term {
  position: relative;
  width: min(960px, 100%);
  height: 86vh;                     /* fallback for old browsers */
  height: min(86dvh, 780px);
  min-height: 420px;
  background: var(--term-bg);
  border: 1px solid var(--edge);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* CRT scanlines + vignette — intensity is per-theme */
.term::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: var(--scanline);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 2px,
      rgba(0, 0, 0, 0.14) 2px 4px
    ),
    radial-gradient(
      ellipse at center,
      transparent 58%,
      rgba(0, 0, 0, 0.24) 100%
    );
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--edge);
  flex: none;
  user-select: none;
}

.dots { display: inline-flex; gap: 7px; }
.dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--dim);
  opacity: 0.55;
}
.dots.ghost { visibility: hidden; }  /* balances the centered title */

.term-title {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.term-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 20px;
  text-shadow: var(--glow);
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}
.term-body::-webkit-scrollbar { width: 8px; }
.term-body::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 4px; }

/* ---------- output lines ---------- */

.line {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-height: 1.45em;
}

.line.banner {
  white-space: pre;
  font-size: clamp(5px, 2.1vw, 14px);
  line-height: 1.18;
  color: var(--bright);
  min-height: 0;
}

.line.no-wrap {
  white-space: pre;
  overflow-x: auto;
  scrollbar-width: none;
}
.line.no-wrap::-webkit-scrollbar { display: none; }

/* big ASCII art (the lion) — one scaled, scrollable block */
.line.art {
  white-space: pre;
  font-size: clamp(3px, 1.15vw, 10px);
  line-height: 1.08;
  min-height: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.line.art::-webkit-scrollbar { display: none; }

/* the static intro (index.html) — crawler / no-JS fallback; boot() removes it */
#static-intro h1, #static-intro p { margin: 0; font-size: inherit; font-weight: inherit; }

.dim    { color: var(--dim); }
.bright { color: var(--bright); }
.ok     { color: var(--ok); }
.warn   { color: var(--warn); }
.err    { color: var(--err); }

a {
  color: var(--link);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
a:hover, a:focus-visible {
  background: var(--fg);
  color: var(--term-bg);
  text-decoration: none;
  outline: none;
}

.swatch { letter-spacing: -1px; }

/* achievement toast — appended straight to the screen when you find one */
.ach-toast {
  color: var(--ok);
  border-left: 2px solid var(--ok);
  padding-left: 8px;
  margin: 3px 0;
}

/* ---------- contrib heatmap ---------- */
/* One square glyph per day; intensity is COLOUR, not glyph density. The five
   shades are mixed from the theme accent, so the graph matches every theme.
   letter-spacing opens the gaps between squares, GitHub-style. */

.heat-row {
  min-height: 0;
  line-height: 1.12;
  text-shadow: none;      /* the glow smears the little squares together */
}
.heat { letter-spacing: 3px; }
.heat-months { color: var(--dim); }

.h0, .h1, .h2, .h3, .h4 { color: var(--ok); }   /* fallback if color-mix is unsupported */
.h0 { color: var(--edge); }
.h1 { color: color-mix(in srgb, var(--ok) 28%, var(--edge)); }
.h2 { color: color-mix(in srgb, var(--ok) 50%, var(--edge)); }
.h3 { color: color-mix(in srgb, var(--ok) 74%, var(--edge)); }
.h4 { color: var(--ok); }

/* clickable command chips */
.chip {
  font: inherit;
  display: inline-block;
  background: none;
  border: 1px solid var(--dim);
  border-radius: 4px;
  color: var(--fg);
  padding: 1px 10px;
  margin: 2px 8px 2px 0;
  cursor: pointer;
  text-shadow: inherit;
}
.chip:hover, .chip:focus-visible {
  background: var(--fg);
  color: var(--term-bg);
  outline: none;
  text-shadow: none;
}

/* ---------- snake ---------- */

.game {
  margin: 6px 0;
  line-height: 1.15;
  user-select: none;
  touch-action: none;      /* swipes steer the snake, they don't scroll the page */
}
.game .line { min-height: 0; color: var(--edge); }

.c-empty { color: var(--edge); opacity: 0.55; }
.c-snake { color: var(--ok); }
.c-head  { color: var(--bright); }
.c-food  { color: var(--warn); }

/* ---------- input line ---------- */

.input-line {
  position: relative;
  display: block;
  overflow-wrap: break-word;
  cursor: text;
}

/* an author `display` beats the UA's [hidden] rule, so restate it —
   otherwise the prompt keeps showing during snake and the exit screen */
.input-line[hidden] { display: none; }

.prompt { user-select: none; }
.p-user { color: var(--ok); }
.p-root { color: var(--err); }
.p-path { color: var(--warn); }

#typed { white-space: pre-wrap; word-break: break-all; }

.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.15em;
  margin-bottom: -0.18em;
  background: var(--fg);
  animation: blink 1.1s steps(1) infinite;
}
.cursor.idle {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--fg);
  animation: none;
}

@keyframes blink { 50% { background: transparent; } }

/* the real input: invisible, stretched over the line, still focusable.
   16px font-size is what stops iOS from zooming in on focus. */
#cli {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  margin: 0;
  font-size: 16px;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  cursor: text;
}

/* ---------- matrix overlay ---------- */

.matrix-canvas {
  position: absolute;
  inset: 0;
  width: 100%;    /* canvas is a replaced element — inset alone won't stretch it */
  height: 100%;
  z-index: 5;
  pointer-events: none;
  transition: opacity 0.6s;
}

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

.page-foot {
  flex: none;
  font-size: 12px;
  color: var(--foot);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.page-foot a { color: var(--foot); }
.page-foot a:hover { background: var(--foot); color: var(--page-bg); }

/* ---------- the printable CV ---------- */

#resume { display: none; }

@media print {
  body { padding: 0; display: block; background: #fff; }
  .term, .page-foot { display: none !important; }

  #resume {
    display: block;
    max-width: 100%;
    color: #111;
    background: #fff;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 10.5pt;
    line-height: 1.5;
  }
  #resume h1 {
    margin: 0;
    font-size: 20pt;
    letter-spacing: 0.02em;
  }
  #resume .r-role {
    margin: 2pt 0 0;
    font-size: 11pt;
  }
  #resume .r-links {
    margin: 4pt 0 14pt;
    font-size: 10pt;
    color: #444;
  }
  #resume h2 {
    margin: 16pt 0 6pt;
    font-size: 10pt;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    border-bottom: 1px solid #999;
    padding-bottom: 3pt;
  }
  #resume h3 {
    margin: 10pt 0 2pt;
    font-size: 11pt;
  }
  #resume h3 span {
    float: right;
    font-weight: normal;
    color: #555;
  }
  #resume dl {
    display: grid;
    grid-template-columns: 90pt 1fr;
    gap: 3pt 0;
    margin: 0;
  }
  #resume dt { color: #555; }
  #resume dd { margin: 0; }
  #resume ul { margin: 4pt 0 0 14pt; padding: 0; }
  #resume .r-foot {
    margin-top: 20pt;
    padding-top: 6pt;
    border-top: 1px solid #ccc;
    font-size: 9pt;
    color: #555;
  }
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  body { padding: 10px 8px 8px; font-size: 13px; }
  .term { height: 90vh; height: min(90dvh, 820px); }
  .term-body { padding: 12px 12px 16px; }
  .game { font-size: 12px; }
  /* tighter squares so a 6-month heatmap fits a 360px phone;
     contrib measures this, so the window adapts automatically */
  .heat { letter-spacing: 2px; }
}

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

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}
