/*
  CV site styles.

  The whole thing is set in the 3270 font, so I leaned into the mainframe look:
  dot-leader rows like an old panel screen, reverse-video headings and a status
  line pinned to the bottom. Light mode is meant to feel like the printout,
  dark mode like the screen.

  Order of this file: font, colours, base, shared bits, then each section top
  to bottom, then print.
*/

/* subset of 3270 (latin + box drawing) so it's only ~10kb. licence is in /fonts */
@font-face {
  font-family: "IBM 3270";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/3270-Regular.woff2") format("woff2");
}

/* ---------- colours + sizes ---------- */

/* light theme is the default. every colour on the page comes from these */
:root {
  --bg: #f2f5ef;
  --surface: #e3ecdf;
  --ink: #13221f;
  --dim: #4a5c56;
  --line: #c3d0c4;
  --leader: #94a69a;
  --accent: #0b6470;
  --ok: #1f6b38;
  --on-accent: #f2f5ef;

  --font: "IBM 3270", "3270", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --t-xs: 0.875rem;
  --t-sm: 1rem;
  --t-base: 1.125rem;
  --t-lg: 1.4375rem;
  --t-hero: clamp(2.6rem, 9.6vw, 6rem);

  --gutter: clamp(16px, 4vw, 40px);
  --nav-h: 3.25rem;
  --status-h: 2.25rem;
  color-scheme: light;
}

/* dark theme. the same values are listed twice on purpose:
   1) system is dark and the visitor hasn't picked light with the toggle
   2) the visitor picked dark with the toggle, whatever the system says */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f15;
    --surface: #111a24;
    --ink: #d5e1e3;
    --dim: #8ea2a8;
    --line: #22303d;
    --leader: #3d5061;
    --accent: #58d3cf;
    --ok: #86dc8f;
    --on-accent: #0a0f15;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0f15;
  --surface: #111a24;
  --ink: #d5e1e3;
  --dim: #8ea2a8;
  --line: #22303d;
  --leader: #3d5061;
  --accent: #58d3cf;
  --ok: #86dc8f;
  --on-accent: #0a0f15;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

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

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

/* scroll-padding stops the sticky nav covering a heading when you jump to it */
html { scroll-padding-top: calc(var(--nav-h) + 1.25rem); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-base);
  font-weight: 400;
  font-synthesis: none; /* 3270 only comes in regular, don't let the browser fake a bold */
  line-height: 1.55;
  /* leave room for the fixed status line at the bottom */
  padding-bottom: calc(var(--status-h) + env(safe-area-inset-bottom, 0px));
}

h1, h2, h3, p, dl, dd, ul { margin: 0; }
h1, h2, h3, strong, b { font-weight: 400; }
ul { padding: 0; list-style: none; }

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

.wrap { max-width: 68rem; margin: 0 auto; padding-inline: var(--gutter); }

/* skip link for keyboard users, only shows when focused */
.skip {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 30;
  background: var(--accent); color: var(--on-accent); padding: 0.35rem 1ch; text-decoration: none;
}
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + 0.5rem); }

/* screen reader only */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- shared bits ---------- */

.label { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.09em; color: var(--dim); }

/* reverse video block, used for the section headings.
   no bold in this font so hierarchy is done with colour and size instead */
.rev {
  display: inline-block; background: var(--accent); color: var(--on-accent);
  padding: 0 1ch; font-size: var(--t-xs); line-height: 1.7; text-transform: uppercase; letter-spacing: 0.09em;
}
.tag {
  display: inline-block; background: var(--ok); color: var(--on-accent);
  padding: 0 1ch; font-size: var(--t-xs); line-height: 1.6; text-transform: uppercase; letter-spacing: 0.09em;
  vertical-align: 0.15em;
}

.btn {
  display: inline-block; font: inherit; font-size: var(--t-sm); line-height: 1.4; cursor: pointer;
  color: var(--accent); background: transparent; border: 1px solid var(--accent); border-radius: 0;
  padding: 0.4rem 1.5ch; text-decoration: none;
}
.btn:hover, .btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.small { font-size: var(--t-xs); padding: 0 1ch; line-height: 1.6; text-transform: uppercase; letter-spacing: 0.06em; }

/*
  "Label . . . . : value" rows.

  The dots are one long string sat behind the label, and the label has a solid
  background so it covers the dots underneath it. That way the dots line up
  down the column no matter how long each label is.

  --label needs to be an ODD number of ch, otherwise the last dot gets cut off.
*/
.rows { --label: 17ch; display: flex; flex-direction: column; gap: 0.2rem; }
.rows > div { display: flex; align-items: baseline; gap: 1ch; min-width: 0; }
.rows dt {
  position: relative; flex: 0 0 var(--label); width: var(--label);
  overflow: hidden; white-space: nowrap; color: var(--dim);
}
.rows dt::before {
  content: ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . .";
  position: absolute; left: 0; top: 0; color: var(--leader);
}
.rows dt span { position: relative; background: var(--row-bg, var(--bg)); padding-right: 1ch; }
/* hanging indent so a value that wraps lines up under itself, not under the colon */
.rows dd { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; padding-left: 2ch; text-indent: -2ch; }
.rows dd > * { text-indent: 0; }
.rows dd::before { content: ": "; color: var(--leader); }

/* striped version for the skills table (greenbar paper, basically) */
.rows.zebra { gap: 0; }
.rows.zebra > div { padding: 0.3rem 1ch; }
.rows.zebra > div:nth-child(odd) { --row-bg: var(--surface); background: var(--surface); }

/* ---------- top nav ---------- */

.nav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.nav-in { display: flex; align-items: center; flex-wrap: wrap; gap: 0 2ch; min-height: var(--nav-h); }
.brand { color: var(--ink); text-decoration: none; font-size: var(--t-sm); text-transform: uppercase; letter-spacing: 0.09em; white-space: nowrap; }
.nav-links { display: flex; flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { color: var(--dim); text-decoration: none; font-size: var(--t-sm); padding: 0.2rem 1ch; }
.nav-links a:hover { background: var(--surface); color: var(--ink); }
.nav-links a[aria-current="true"] { background: var(--accent); color: var(--on-accent); } /* set from main.js */

.theme { display: flex; flex: 0 0 auto; margin-left: auto; border: 1px solid var(--line); }
.theme button {
  font: inherit; font-size: var(--t-xs); line-height: 1.7; text-transform: uppercase; letter-spacing: 0.06em;
  background: transparent; color: var(--dim); border: 0; border-radius: 0; padding: 0 1ch; cursor: pointer;
}
.theme button:hover { color: var(--ink); }
.theme button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* on phones the links drop to their own row and scroll sideways */
@media (max-width: 780px) {
  :root { --nav-h: 5rem; }
  .nav-in { padding-block: 0.45rem; row-gap: 0.3rem; }
  .nav-links { order: 3; flex-basis: 100%; margin-inline: -1ch; }
}

/* ---------- intro ---------- */

.hero { padding-block: clamp(2.25rem, 6vw, 4.5rem) clamp(2.5rem, 6vw, 4.5rem); }
.eyebrow { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 2ch; }
.hero h1 {
  font-size: var(--t-hero); line-height: 0.98;
  letter-spacing: -0.045em; /* the font is quite gappy at this size */
  margin-top: 0.3em; text-wrap: balance;
}

/* block cursor after my name. blinks 4 times then stays solid so it isn't distracting */
.cursor {
  display: inline-block; width: 0.54em; height: 0.78em; margin-left: 0.12em;
  background: var(--accent); vertical-align: baseline;
}
@media (prefers-reduced-motion: no-preference) {
  .cursor { animation: blink 1.1s steps(1, end) 4; }
}
@keyframes blink { 50% { opacity: 0; } }

.hero-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; margin-top: clamp(1.75rem, 4vw, 2.75rem); }
.hero-lead { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.lead { font-size: var(--t-lg); line-height: 1.4; max-width: 34ch; text-wrap: pretty; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5ch; }
@media (min-width: 880px) {
  .hero-cols { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 3.5rem; align-items: start; }
}

/* ---------- sections ---------- */

main { display: block; }
.sec { border-top: 1px solid var(--line); padding-block: clamp(2rem, 5vw, 3.25rem); }
.sec-in { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.sec-body { min-width: 0; max-width: 46rem; } /* keeps lines to a readable length */

/* desktop: heading sits in a left column and sticks while you read the section */
@media (min-width: 880px) {
  .sec-in { grid-template-columns: 12rem minmax(0, 1fr); gap: 2rem; }
  .sec-label { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--nav-h) + 1.25rem); align-self: start; }
}

.prose { display: flex; flex-direction: column; gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: 2.25rem; }

/* one job / course / project */
.entry h3 { font-size: var(--t-lg); line-height: 1.25; text-wrap: balance; }
.entry .meta { color: var(--dim); font-size: var(--t-sm); margin-top: 0.2rem; }
.entry .meta .org { color: var(--accent); }
.entry .note { margin-top: 0.6rem; }

.points { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
.points li { position: relative; padding-left: 2ch; }
.points li::before { content: "-"; position: absolute; left: 0; color: var(--accent); }

/* sub-block inside a section, e.g. certifications under education */
.sub { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px dashed var(--line); }
.sub > h3 { margin-bottom: 0.75rem; }
.sub .points { margin-top: 0; }

/* label widths for each rows list (odd numbers, see the note above) */
.rows.skills { --label: 25ch; }
.rows.contact { --label: 13ch; gap: 0.5rem; }
.rows.grades { --label: 21ch; margin-top: 0.6rem; }
.rows.bands { --label: 11ch; margin-top: 0.6rem; }
.rows.contact dd .btn { margin-left: 1ch; }

/* skills labels are too wide for a phone, so stack label over value there */
@media (max-width: 640px) {
  .rows.skills > div { flex-direction: column; gap: 0; }
  .rows.skills dt { flex: 0 0 auto; width: auto; }
  .rows.skills dt::before, .rows.skills dd::before { content: none; }
  .rows.skills dt span { padding-right: 0; }
  .rows.skills dd { flex: 0 0 auto; padding-left: 0; text-indent: 0; }
  .rows.contact dd .btn { margin-left: 0; }
}
@media (max-width: 480px) {
  body { font-size: 1.0625rem; }
  .rows { --label: 15ch; }
  .rows.contact { --label: 11ch; }
}

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

.foot { border-top: 1px solid var(--line); color: var(--dim); font-size: var(--t-sm); }
.foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 3ch; padding-block: 1.5rem 2rem; }
.foot p { max-width: 60ch; }

/* ---------- status line ---------- */

/* fixed bar at the bottom, a nod to the status line on a real 3270 terminal.
   shows which section you're in, updated from main.js */
.status {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--bg); border-top: 1px solid var(--accent);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim);
}
.status-in { display: flex; align-items: center; gap: 2ch; height: var(--status-h); white-space: nowrap; }
.status-id { border: 1px solid var(--dim); padding: 0 0.5ch; line-height: 1.35; letter-spacing: 0; }
.status-path { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.status-sec { color: var(--accent); margin-left: auto; }
.status-pos { color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .status-path { display: none; } }

/* ---------- print ---------- */

/* so ctrl+p gives a normal paper CV: black on white, no nav, no buttons.
   the tripled :root is just to beat the specificity of the dark theme rules */
@media print {
  :root:root:root {
    --bg: #fff; --surface: #f0f0f0; --ink: #000; --dim: #333; --line: #bbb; --leader: #999;
    --accent: #000; --ok: #000; --on-accent: #fff;
    color-scheme: light;
  }
  body { font-size: 10.5pt; padding-bottom: 0; }
  .nav, .status, .skip, .actions, .btn, .cursor { display: none !important; }
  .hero { padding-block: 0 1.25rem; }
  .hero h1 { font-size: 30pt; }
  .hero-cols { grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 1rem; }
  .sec { padding-block: 1rem; }
  .sec-in { grid-template-columns: 8rem minmax(0, 1fr); gap: 1rem; }
  .sec-label { position: static; }
  .stack { gap: 1.25rem; }
  .entry, .rows > div { break-inside: avoid; page-break-inside: avoid; }
  .rev, .tag, .rows.zebra > div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
}
