/* choda.org - a CV in an Ubuntu terminal: GNOME Terminal with the Yaru header bar, aubergine
   background, Ubuntu Mono and the Tango colours Ubuntu shows for bold text. */

:root {
  color-scheme: dark;
  --page: #1b1b1b;
  --window: #300a24;
  --bar: #2c2c2c;
  --bar-button: #3d3d3d;
  --border: #1f1f1f;
  --text: #ffffff;
  --muted: #9e8a99;
  --green: #8ae234;
  --blue: #729fcf;
  --cyan: #34e2e2;
  --yellow: #fce94f;
  --magenta: #ad7fa8;
  --red: #ff6b6b;
  --orange: #e95420;
  --font: 'Ubuntu Mono', ui-monospace, 'DejaVu Sans Mono', Consolas, monospace;
  --ui-font: 'Ubuntu', system-ui, sans-serif;
  --size: 16px;
  --lh: 1.35;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(233, 84, 32, 0.22), transparent 65%),
    radial-gradient(1000px 640px at 90% 110%, rgba(119, 33, 111, 0.45), transparent 65%),
    var(--page);
  color: var(--text);
  font: var(--size)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(255, 255, 255, 0.28); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Window */
.window {
  display: flex;
  flex-direction: column;
  width: min(1000px, 100%);
  height: min(820px, calc(100vh - 48px));
  height: min(820px, calc(100dvh - 48px));
  background: var(--window);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* Yaru header bar: centred title, tool buttons, then minimise / maximise / close. Decorative. */
.titlebar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 46px;
  padding: 0 10px;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
}
.title {
  position: absolute;
  left: 150px;
  right: 150px;
  overflow: hidden;
  color: var(--text);
  font: 700 14px/46px var(--ui-font);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.controls { display: flex; align-items: center; gap: 4px; color: #f6f5f4; }
.controls i { display: grid; place-items: center; }
.controls .tool { width: 34px; height: 34px; border-radius: 6px; }
.controls .tool svg { width: 16px; height: 16px; }
.controls .tool + .win { margin-left: 10px; }
.controls .win { width: 24px; height: 24px; margin-left: 6px; border-radius: 50%; background: var(--bar-button); }
.controls .win svg { width: 10px; height: 10px; }
.controls .close { background: var(--orange); color: #fff; }

/* Scrollback */
.screen {
  position: relative; /* offsetTop of output lines is measured from here */
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.line {
  min-height: calc(var(--lh) * 1em);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-left: var(--hang, 0);
  text-indent: calc(-1 * var(--hang, 0));
}

/* Fixed-width art: the banner (41 columns) and the Enigma machine (42). Ubuntu Mono's ascent +
   descent is exactly 1em, so at line-height 1 rows of block and box glyphs join. Glyphs are 0.5em
   wide, so the font size is bound to fit the columns into a phone's width. */
.line.banner,
.line.machine {
  width: fit-content;
  min-height: 0;
  white-space: pre;
  line-height: 1;
  font-size: min(var(--size), calc((100vw - 24px) / 21.5));
}

.line.banner {
  filter: url(#seal); /* closes the hairline between neighbouring blocks, see index.html */
  background: linear-gradient(90deg, var(--orange), #f99b11);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.c-green { color: var(--green); }
.c-blue { color: var(--blue); }
.c-cyan { color: var(--cyan); }
.c-yellow { color: var(--yellow); }
.c-magenta { color: var(--magenta); }
.c-red { color: var(--red); }
.c-muted { color: var(--muted); }
.c-bold { font-weight: 700; }
.c-glow { text-shadow: 0 0 6px rgba(252, 233, 79, 0.9), 0 0 14px rgba(252, 233, 79, 0.5); }

a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: rgba(52, 226, 226, 0.4);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: currentColor; }

.cmd-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--cyan);
  font: inherit;
  text-indent: 0; /* inline-block: do not inherit the line's hanging indent */
  text-decoration: underline dotted rgba(52, 226, 226, 0.6);
  text-underline-offset: 3px;
  cursor: pointer;
}
.cmd-link:hover { color: var(--text); text-decoration-color: currentColor; }

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

/* Prompt */
.prompt-line { display: flex; align-items: baseline; gap: 1ch; }
.prompt { flex: none; white-space: pre; }
.input-wrap { position: relative; flex: 1; min-width: 0; }

#cmd {
  width: 100%;
  height: calc(var(--lh) * 1em);
  padding: 0;
  border: 0;
  outline: 0; /* focus is shown by the cursor turning solid */
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: var(--lh);
  caret-color: transparent;
}

/* GNOME Terminal's block cursor fills the whole character cell. */
.cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 1ch;
  height: calc(var(--lh) * 1em);
  background: var(--text);
  opacity: 0.85;
  pointer-events: none;
  animation: blink 1.1s steps(1) infinite;
}
.cursor.hidden { visibility: hidden; }
.prompt-line:not(:focus-within) .cursor {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--text);
  animation: none;
}
@keyframes blink { 50% { opacity: 0; } }

/* Quick commands */
.quickbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 8px 12px;
  background: var(--bar);
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.quickbar-label { flex: none; white-space: nowrap; color: var(--muted); }
.quickbar-label::after { content: ' ›'; color: var(--green); }
.quickbar button {
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--bar-button);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.quickbar button:hover { border-color: var(--orange); }

@media (max-width: 640px) {
  :root { --size: 15px; }
  body { padding: 0; }
  .window { width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
  .titlebar { min-height: 40px; }
  .title { left: 44px; right: 44px; font-size: 13px; line-height: 40px; }
  .controls .tool, .controls .win:not(.close) { display: none; }
  .screen { padding: 12px; }
  .input-wrap { font-size: 16px; } /* 16px+ keeps iOS from zooming in on focus; the cursor's ch follows */
  .quickbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .quickbar button { flex: none; }
}

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