/* ============================================================
   veskov.dev :: terminal theme
   ============================================================ */
:root {
  --desk:      #040604;
  --winw:      1100px;
  --bg:        #0b0f0b;
  --bg-panel:  #0e140e;
  --chrome:    #111811;
  --fg:        #b8ffcc;
  --green:     #46ff8a;
  --green-dim: #2ea864;
  --amber:     #ffb347;
  --red:       #ff5f56;
  --yellow:    #ffbd2e;
  --cyan:      #5be7e9;
  --dim:       #74957f;
  --border:    #1d2b20;
  --glow:      0 0 6px rgba(70, 255, 138, .35);
  --font:      'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* the body is the desktop: it holds one terminal window and never scrolls */
body {
  background:
    radial-gradient(1100px 700px at 18% -12%, rgba(70, 255, 138, .05), transparent 60%),
    radial-gradient(900px 620px at 108% 112%, rgba(91, 231, 233, .04), transparent 60%),
    var(--desk);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex; flex-direction: column;
}

::selection { background: var(--green); color: #04140a; }

/* ---------- The desktop's top bar: full-wide, links on the right ---------- */
.topnav {
  width: 100%;
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
  padding: .2rem 1.1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.nav-brand { color: var(--dim); font-size: 13px; margin-right: auto; }
.topnav a {
  color: var(--green-dim); text-decoration: none; font-size: 13px;
  padding: .3rem .3rem;
  transition: color .15s, text-shadow .15s;
}
.topnav a:hover { color: var(--green); text-shadow: var(--glow); }

/* ---------- The window ---------- */
/* the workspace between the bars */
.desk { position: relative; flex: 1; min-height: 0; }

.window {
  position: absolute;
  left: 4%; top: 7%;
  /* the opening size scales with the screen: two thirds wide, 8:5 like a
     terminal, capped for ultrawides and for short desks; a drag or resize
     replaces all of this with inline px and the ratio steps aside */
  width: min(66%, 1560px);
  aspect-ratio: 8 / 5;
  max-height: 86%;
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 1px solid #27402c;
  border-radius: 10px;
  overflow: hidden; /* the radius clips the scanlines and the boot overlay too */
  box-shadow:
    0 0 0 1px rgba(70, 255, 138, .09),
    0 30px 90px rgba(0, 0, 0, .8),
    0 12px 36px rgba(0, 0, 0, .55),
    0 0 80px rgba(70, 255, 138, .08);
  transition: opacity .3s ease, transform .3s cubic-bezier(.33, 1.3, .55, 1);
}
/* JS holds the window closed until the OS has booted; without JS it never is */
.window.pre-open { opacity: 0; transform: scale(.94); }
/* once JS manages the geometry in px, the opening ratio and caps step aside */
.window.managed { aspect-ratio: auto; max-height: none; }
.window.maximized { border-radius: 0; }
/* only the maximize toggle animates: dragging must track the cursor 1:1 */
.window.animating {
  transition: left .22s ease, top .22s ease,
              width .22s ease, height .22s ease, border-radius .22s ease;
}

/* ---------- CRT effects: absolute, so they live on the screen ---------- */
.scanlines {
  position: absolute; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 2px,
    rgba(0, 0, 0, .18) 3px, rgba(0, 0, 0, .18) 4px
  );
  mix-blend-mode: multiply;
}
.vignette {
  position: absolute; inset: 0; z-index: 51; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
}

/* ---------- Boot overlay: the whole machine boots, black screen ---------- */
#boot {
  position: fixed; inset: 0; z-index: 100;
  background: #020402;
  padding: 2rem;
  font-size: 14px;
  white-space: pre-wrap;
  color: var(--green);
  text-shadow: var(--glow);
  transition: opacity .5s ease;
}
#boot.done { opacity: 0; pointer-events: none; }
/* the log is a <pre>: UA white-space/font beat the inherited ones, so restate them */
#boot-log {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Window chrome: title bar + menu bar ---------- */
.titlebar {
  display: flex; align-items: center;
  padding: .55rem .9rem;
  background: linear-gradient(var(--chrome), #0c120c);
  border-bottom: 1px solid var(--border);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
@media (min-width: 701px) {
  .titlebar { cursor: grab; }
  .titlebar:active { cursor: grabbing; }
  .titlebar .dot { cursor: pointer; }
}

/* the grip in the corner: three diagonal ridges, like every WM ever */
.win-resize {
  position: absolute; right: 2px; bottom: 2px; z-index: 55;
  width: 18px; height: 18px;
  cursor: nwse-resize;
  touch-action: none;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  background: repeating-linear-gradient(135deg,
    transparent 0 4px, var(--green-dim) 4px 6px);
  opacity: .55;
  border-bottom-right-radius: 8px;
}
@media (hover: hover) { .win-resize:hover { opacity: 1; } }
.titlebar-btns { display: flex; gap: 8px; width: 64px; flex: none; }
/* the buttons do things (exit, clear, fullscreen), so they are real buttons */
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: none; padding: 0; display: inline-block; cursor: pointer;
}
.dot.red    { background: var(--red); }
.dot.yellow { background: var(--yellow); }
.dot.green  { background: #27c93f; }
@media (hover: hover) {
  .dot:hover { filter: brightness(1.25); }
}
.titlebar-title {
  flex: 1; text-align: center;
  color: var(--dim); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.titlebar-spacer { width: 64px; flex: none; }

/* ---------- The screen: the only thing that scrolls ---------- */
.viewport {
  flex: 1; overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--green-dim) transparent;
}
.viewport::-webkit-scrollbar { width: 10px; }
.viewport::-webkit-scrollbar-track { background: transparent; }
.viewport::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 5px;
  border: 2px solid var(--bg);
}
.viewport::-webkit-scrollbar-thumb:hover { background: var(--green-dim); }

/* ---------- Terminal layout ---------- */
#term {
  padding: 1.2rem 1.4rem 2.6rem;
}

/* the nav and title bar sit outside the scroll area, so nothing can hide
   behind them; the margin is breathing room when a nav link scrolls back */
#history .h-line,
#history .out { scroll-margin-top: .6rem; }

.prompt { color: var(--green); text-shadow: var(--glow); font-weight: 700; }
.path   { color: var(--cyan); }
.dim    { color: var(--dim); }
.err    { color: var(--red); }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-shadow: 0 0 6px rgba(91, 231, 233, .5); }

.cursor {
  display: inline-block; width: .62em; height: 1.15em;
  background: var(--green); vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1.06s step-end infinite;
  box-shadow: var(--glow);
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- History entries ---------- */
.h-line { white-space: pre-wrap; word-break: break-word; }
.h-line .cmd { color: var(--fg); }

/* output block: appears instantly after a command is typed */
.out {
  margin: .35rem 0 1.6rem;
  white-space: pre-wrap; word-break: break-word;
}
.out p { margin-bottom: .9rem; max-width: 68ch; white-space: normal; }

/* ---------- whoami output ---------- */
.who-name {
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  font-weight: 700; color: var(--green);
  text-shadow: var(--glow), 0 0 24px rgba(70,255,138,.18);
  letter-spacing: 0;
  line-height: 1.15;
  white-space: normal;
}
.who-sub { color: var(--fg); margin-top: .2rem; white-space: normal; }
.who-sub.dim { color: var(--dim); font-size: 14px; margin-top: .05rem; }

/* ---------- experience output ---------- */
.job { margin-bottom: 1.4rem; white-space: normal; max-width: 68ch; }
.job .j-role { color: var(--green); font-weight: 700; }
.job .j-org  { color: var(--cyan); font-size: 14px; }
.job .j-when { font-size: 13px; margin-bottom: .3rem; }
.job .j-desc { color: var(--fg); font-size: 15px; }

/* subtle glitch on hover, pointer only: on touch the effect would stick */
.glitch { position: relative; display: inline-block; }
@media (hover: hover) {
  .glitch:hover::before,
  .glitch:hover::after {
    content: attr(data-text);
    position: absolute; inset: 0; overflow: hidden;
  }
  .glitch:hover::before { color: var(--red);  animation: glitch-a .3s steps(2) infinite; }
  .glitch:hover::after  { color: var(--cyan); animation: glitch-b .3s steps(2) infinite; }
}
@keyframes glitch-a { 0%{transform:translate(2px,-1px)} 50%{transform:translate(-2px,1px)} 100%{transform:translate(1px,0)} }
@keyframes glitch-b { 0%{transform:translate(-2px,1px)} 50%{transform:translate(2px,-1px)} 100%{transform:translate(-1px,0)} }

/* ---------- about output ---------- */
.skill-list { display: flex; flex-direction: column; gap: .45rem; margin: .3rem 0 .5rem; white-space: normal; }
.skill-group { display: flex; align-items: baseline; gap: .7rem; }
.skill-label { flex: 0 0 14ch; font-size: 13px; }
.skill-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag {
  border: 1px solid var(--border); border-radius: 4px;
  padding: .1rem .55rem; font-size: 13px; color: var(--green-dim);
  background: var(--bg-panel);
}
/* the three the job hunt actually runs on */
.tag.tag-core { border-color: var(--amber); color: var(--amber); }

/* ---------- projects output ---------- */
/* real terminals clip long lines, they do not reflow them */
.ls-block { font-size: 13px; margin-bottom: 1rem; white-space: pre; overflow-x: auto; }
.projects-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  white-space: normal;
}
.project {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  padding: 1rem 1.1rem;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  display: flex; flex-direction: column; gap: .55rem;
}
.project:hover {
  border-color: var(--green-dim);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(70, 255, 138, .07);
}
.project .p-name { color: var(--green); font-weight: 700; }
.project .p-name::before { content: "▸ "; color: var(--amber); }
.project .p-desc { color: var(--fg); font-size: 14px; flex: 1; }
.project .p-stack { color: var(--dim); font-size: 13px; }
.project .p-links { display: flex; gap: 1rem; font-size: 14px; }
.project .p-links a::before { content: "[→] "; color: var(--amber); }
.project .p-note { font-size: 13px; font-style: italic; }

/* ---------- contacts output ---------- */
.contact-row { display: flex; gap: 1rem; padding: .15rem 0; }
.contact-row .c-key { color: var(--amber); min-width: 92px; }

/* ---------- status output ---------- */
/* systemctl's own column widths: this one clips like a terminal, never reflows */
.status-block { font-size: 13px; white-space: pre; overflow-x: auto; }
.status-dot   { color: var(--green); text-shadow: var(--glow); }

/* ---------- cv output ---------- */
.cv-row { display: flex; gap: 1rem; padding: .15rem 0; }
.cv-row a { min-width: 12rem; }
.cv-tip { margin-top: .6rem; }

/* ---------- references output ---------- */
/* dormant while CONFIG.references is empty, dressed for the day it is not */
.quote {
  border-left: 2px solid var(--border);
  padding-left: 1rem; margin-bottom: 1.3rem;
  white-space: normal; max-width: 68ch;
}
.quote .q-text { margin-bottom: .2rem; }
.quote .q-by   { font-size: 13px; }

/* ---------- tab completion ---------- */
/* bash prints the options tight against the line it is completing */
.out.tab-list { margin: .1rem 0 .7rem; }

/* ---------- help output ---------- */
.help-row { display: grid; grid-template-columns: 12rem 1fr; gap: .5rem; }
.help-tip { margin-top: .9rem; }

/* ---------- live prompt ---------- */
/* no gap: the block cursor has to sit on the text, not a third of a word away */
#prompt-form {
  display: flex; align-items: center;
  margin: .25rem 0 3rem;
}
#prompt-form label { margin-right: .5rem; }
/* JS keeps the width at the length of the value, so the cursor follows the text */
#prompt-input {
  flex: 0 1 auto; min-width: 1ch; max-width: 100%;
  background: transparent; border: none; outline: none;
  color: var(--fg); font-family: var(--font); font-size: inherit;
  line-height: 1.65; padding: 0;
  caret-color: transparent; /* the .cursor block is the caret */
}
/* The input reserves one cell past the text so nothing clips; the block is pulled
   back onto it, which is where a real terminal parks its cursor. Same font and
   size as the input, so the 1ch cancels exactly whichever family wins.
   The block doubles as the prompt's focus indicator: hollow when the input does
   not have focus, solid and blinking when it does (or while the session types) */
#prompt-form .cursor {
  font-size: inherit; margin-left: -1ch;
  background: transparent; box-shadow: none;
  border: 1px solid var(--green); animation: none;
}
#prompt-form:focus-within .cursor,
#prompt-input[readonly] + .cursor {
  background: var(--green); border-color: var(--green);
  box-shadow: var(--glow);
  animation: blink 1.06s step-end infinite;
}

/* ---------- skip affordance ---------- */
.skip-hint {
  position: absolute; right: 14px; bottom: 12px; z-index: 60;
  font: inherit; font-size: 12px; line-height: 1;
  color: var(--dim); background: transparent;
  border: 1px solid currentColor; border-radius: 3px;
  padding: 8px 10px; opacity: .75; cursor: pointer;
}

/* ---------- focus ---------- */
.topnav a:focus-visible,
.titlebar .dot:focus-visible,
#term a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 2px;
}
.titlebar .dot:focus-visible { border-radius: 50%; }
/* the two blocks that scroll sideways are focusable, so they have to say so */
.status-block:focus-visible,
.ls-block:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ---------- Footer: the desktop's status bar, under the window ---------- */
.deskfoot {
  width: 100%;
  padding: .3rem 1.1rem;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 13px;
}

/* touch keyboards zoom into sub-16px inputs, so the whole terminal (prompt
   included, via inherit) steps up to 16px there; typed and committed lines
   stay the same size on every device */
@media (pointer: coarse) {
  body { font-size: 16px; }
}

/* small screens: the window goes full-bleed, the desktop steps aside */
@media (max-width: 700px) {
  #boot { padding: 1.25rem 1rem; font-size: 13px; }
  .topnav { padding: .15rem .9rem; }
  .topnav a { padding: .55rem .3rem; }
  /* !important: a phone rotation must beat whatever a desktop drag left inline */
  .window {
    left: 0 !important; top: 0 !important;
    width: 100% !important; height: 100% !important;
    aspect-ratio: auto; max-height: none;
    border: none; border-radius: 0; box-shadow: none;
  }
  .win-resize { display: none; }
  .deskfoot { display: none; }
}

@media (max-width: 560px) {
  .topnav { gap: .9rem; }
  .nav-brand { display: none; }
  /* the bar is narrow: buy the bigger type back out of the horizontal padding */
  .topnav a { font-size: 13px; padding: .55rem 0; }
  .contact-row,
  .cv-row { flex-direction: column; gap: 0; }
  /* man-page shape: command, then its description indented underneath */
  .help-row { grid-template-columns: 1fr; gap: 0; margin-bottom: .45rem; }
  .help-row .help-desc { color: var(--dim); padding-left: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .window { transition: none; }
  .window.animating { transition: none; }
  .cursor,
  #prompt-form:focus-within .cursor,
  #prompt-input[readonly] + .cursor { animation: none; }
  .glitch:hover::before,
  .glitch:hover::after { animation: none; }
}

/* ---------- noscript fallback: classes only, so a CSP without
   'unsafe-inline' for styles can ship later ---------- */
.noscript-card { border: 1px solid var(--border); padding: 1.2rem; margin: 1.5rem 0; }
.noscript-card .ns-name { color: var(--green); font-weight: 700; }
.noscript-card p + p { margin-top: 1rem; }

/* ---------- a11y utility ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
