/* site.css – adrianmaciejewski.github.io.
   Same typeface, ink and ornaments as the CV (code/src/base.css and code/src/cv/style.css on
   main), adapted to the screen: a fluid single column, a dark theme that follows the system
   setting, and no fixed A4 page. */

/* ---- Settings ------------------------------------------------------------ */
:root {
  color-scheme: light dark;

  --paper: #fdfdfc;        /* page background */
  --ink: #1d1d1f;          /* text, section marks, timeline (as on the CV) */
  --muted: #57575d;        /* dates, organisations, captions (7:1 on paper) */
  --rule: #dcdcdf;         /* hairlines and chart grid */
  --link: #0b5cad;         /* the CV's link colour (6.5:1 on paper) */
  --link-line: rgb(11 92 173 / 0.35);   /* resting underline */
  --series: #0b5cad;       /* data in the figures */
  --pixel: #ededef;        /* empty pixels in Figures 1 and 2 */
  --series-faint: #b6cbe1; /* pixels erosion removes in Figure 2 */
  --selection: #d9e6f6;
  /* Figure 1's attenuation ramp: none (an empty pixel), the series colour, the most. Hex only,
     the script reads them. */
  --ct-lo: #ededef;
  --ct-mid: #0b5cad;
  --ct-hi: #071f3d;

  /* Timeline marker, drawn as on the CV: outer ink diamond, a ring in the paper colour, inner
     ink diamond. 16 = size; 5.17 = 8 - 2*sqrt(2) (outline); 3.05 = 5.17 - 1.5*sqrt(2) (gap).
     The paper ring also hides the line behind the marker. */
  --diamond: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpolygon points='8,0 16,8 8,16 0,8' fill='%231d1d1f'/%3E%3Cpolygon points='8,2.83 13.17,8 8,13.17 2.83,8' fill='%23fdfdfc'/%3E%3Cpolygon points='8,4.95 11.05,8 8,11.05 4.95,8' fill='%231d1d1f'/%3E%3C/svg%3E");

  --font: "Georgia Text", Georgia, serif;
  --measure: 38rem;        /* text column, about 65 characters */
  --margin-col: 7.5rem;    /* dates hang in this column */
  --gap: 2.75rem;          /* between the date column and the text; the timeline runs in it */
  --title-line: 1.575rem;  /* line box of an entry title (1.125rem * 1.4), centres the marker */
}

/* Screen only, so a printout always uses the light theme. */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --paper: #171716;
    --ink: #e7e5e0;
    --muted: #a8a7a2;      /* 7.4:1 */
    --rule: #38383a;
    --link: #8db9f2;       /* 8.9:1 */
    --link-line: rgb(141 185 242 / 0.4);
    --series: #4f93e6;     /* 5.7:1, inside the dark lightness band for chart marks */
    --pixel: #262625;
    --series-faint: #34506f;
    --selection: #2b3b52;
    --ct-lo: #262625;
    --ct-mid: #3f82d4;
    --ct-hi: #e3eefc;
    --diamond: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpolygon points='8,0 16,8 8,16 0,8' fill='%23e7e5e0'/%3E%3Cpolygon points='8,2.83 13.17,8 8,13.17 2.83,8' fill='%23171716'/%3E%3Cpolygon points='8,4.95 11.05,8 8,11.05 4.95,8' fill='%23e7e5e0'/%3E%3C/svg%3E");
  }
}

/* Gelasio: a free Georgia clone (SIL OFL, licence in fonts/OFL.txt), the CV's font. Its default
   figures are old-style, which suit running text; dates and data switch to lining figures. */
@font-face { font-family: "Georgia Text"; font-weight: 400; font-display: swap;
  src: url("fonts/Gelasio-Regular.woff2") format("woff2"); }
@font-face { font-family: "Georgia Text"; font-weight: 700; font-display: swap;
  src: url("fonts/Gelasio-Bold.woff2") format("woff2"); }
@font-face { font-family: "Georgia Text"; font-weight: 400; font-style: italic; font-display: swap;
  src: url("fonts/Gelasio-Italic.woff2") format("woff2"); }

/* ---- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.125rem / 1.6 var(--font);
}
h1, h2, h3, p, ul, figure, table { margin: 0; }
ul { padding: 0; list-style: none; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
sub { font-size: 0.7em; line-height: 0; }
::selection { background: var(--selection); }

a {
  color: var(--link);
  text-decoration: underline 1px var(--link-line);
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 1px; }

.page {
  max-width: calc(var(--margin-col) + var(--gap) + var(--measure) + 3rem);
  margin: 0 auto;
  padding: 5rem 1.5rem 2.5rem;
}

/* ---- Masthead ------------------------------------------------------------ */
/* Name and role carry the CV's section mark, drawn full height as on the link-preview
   image. Under them the page grid begins: the links in the margin column, where the dates
   go, and the introduction in the text column, where the entries go. */
.masthead {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, var(--measure));
  column-gap: var(--gap);
  align-items: baseline;   /* the first link sits on the introduction's first line */
  margin-bottom: 5rem;
}
.name {
  position: relative;
  grid-column: 1 / -1;
  margin-bottom: 2.75rem;
  padding-left: calc(6px + 0.75rem);   /* the mark, then as between a mark and its title */
}
.name::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--ink);
}
.masthead h1 { font-size: clamp(1.75rem, 1.2rem + 2.8vw, 2.875rem); line-height: 1.1; }
.role { margin-top: 0.4rem; color: var(--muted); font-style: italic; }
.contact { font-size: 0.9375rem; line-height: 1.9; }
.intro { font-size: 1.25rem; line-height: 1.55; }
.intro p + p { margin-top: 1rem; }

/* On load the mark is drawn from the top and the masthead settles in after it. */
@media (prefers-reduced-motion: no-preference) {
  .name::before { transform-origin: 50% 0; animation: draw-mark 0.7s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
  .name h1, .name .role, .contact, .intro { animation: settle 0.8s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
  .name h1 { animation-delay: 0.12s; }
  .name .role { animation-delay: 0.22s; }
  .contact, .intro { animation-delay: 0.34s; }
  section { animation: settle 0.8s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
  #education { animation-delay: 0.44s; }
  #experience { animation-delay: 0.50s; }
  #thesis, #projects, #skills { animation-delay: 0.55s; }
}
@keyframes draw-mark { from { transform: scaleY(0); } }
@keyframes settle { from { opacity: 0; transform: translateY(0.35rem); } }

/* Shown to screen readers only. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* Interactive parts need the script (it sets .js on <html> before the first paint). */
html:not(.js) .ct, html:not(.js) .js-only { display: none; }

/* ---- Sections ------------------------------------------------------------ */
section + section { margin-top: 4.5rem; }

/* Section title: the CV's black mark, the title in spaced capitals, a hairline to the edge.
   (The CV puts the title on a grey band that tapers into the line; on screen the band alone
   reads heavier than the text it introduces, so only the mark and the line remain.) */
h2 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  font-size: 0.8125rem;
  line-height: 1.5rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
h2::before { content: ""; flex: none; width: 6px; height: 1.5rem; background: var(--ink); }
h2::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* ---- Entries: date in the margin column, text in the measure ---------------- */
.entry {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, var(--measure));
  column-gap: var(--gap);
  align-items: baseline;   /* the date sits on the title's baseline */
}
.entry + .entry { margin-top: 2.25rem; }
.when {
  font-size: 0.9375rem;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}
.what > * + * { margin-top: 0.5rem; }
.what h3 { font-size: 1.125rem; line-height: 1.4; }
.meta { color: var(--muted); font-style: italic; }
.links { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }

/* Smaller projects: a lighter version of the section title, in the text column, then
   run-in titles, one paragraph each. */
.subhead {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 3.5rem 0 1.5rem calc(var(--margin-col) + var(--gap));
  font-size: 0.8125rem;
  line-height: 1.5rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.subhead::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.entry.brief + .entry.brief { margin-top: 1rem; }

/* Course grades: course names left, grades in a column of lining figures. */
.grades {
  border-collapse: collapse;
  font-size: 1rem;
  font-variant-numeric: lining-nums tabular-nums;
}
.grades th, .grades td {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--rule);
  font-weight: 400;
  text-align: left;
  vertical-align: baseline;
}
.grades td { padding-left: 2.5rem; text-align: right; white-space: nowrap; }
.grades tr:last-child > * { border-bottom: 0; }
.grades .pending { color: var(--muted); font-style: italic; }
.note { font-size: 0.9375rem; color: var(--muted); }

/* Skills: the labels hang in the margin column, like the dates. */
.skills dd { margin: 0; }
.skills .entry + .entry { margin-top: 1rem; }

/* ---- Timeline: a line with the CV's nested diamond at each entry -------------- */
.timeline {
  --marker-x: calc(var(--margin-col) + var(--gap) / 2 - 8px);   /* marker's left edge */
  --marker-y: calc(var(--title-line) / 2 - 8px);                /* marker's top edge */
  --taper: 12px;
  position: relative;
}
/* The line starts at the first marker's centre and ends in a point, as on the CV. */
.timeline::before {
  content: "";
  position: absolute;
  left: calc(var(--marker-x) + 7px);
  top: calc(var(--marker-y) + 8px);
  bottom: 0;
  width: 2px;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--taper)), 50% 100%, 0 calc(100% - var(--taper)));
}
.timeline .entry { position: relative; }
.timeline .entry::before {
  content: "";
  position: absolute;
  left: var(--marker-x);
  top: var(--marker-y);
  width: 16px;
  height: 16px;
  background: var(--diamond) center / contain no-repeat;
}

/* ---- Figure 1: tomography ----------------------------------------------------
   Three square panels: the object, the measurements (one column per angle, the sinogram) and
   the reconstruction. The images are 128 x 128 canvases, scaled smoothly; the measurements keep
   hard pixel edges so each measured angle reads as its own column. */
.ct { margin-top: 1.5rem; }
.ct-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1;
  color: var(--muted);
}
.ct-panels canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  background: var(--ct-lo);
}
.ct-sino { image-rendering: pixelated; }

.ct-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.75rem;
  margin-top: 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}
.ct-controls output { color: var(--ink); font-weight: 700; }
.ct-angles { display: flex; align-items: center; gap: 0.75rem; }
.ct-n { display: inline-block; min-width: 3ch; }
.ct-error { margin-left: auto; }

/* Radiation switch: two square segments, the chosen one in ink, like the section marks. */
.seg { display: inline-flex; margin: 0; padding: 0; border: 1px solid var(--ink); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: block; padding: 0.3rem 0.8rem; line-height: 1.3; color: var(--ink); }
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }

/* Slider: a hairline track, inked up to the thumb, and the timeline's diamond as the thumb. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 10rem;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(var(--ink), var(--ink)) 0 / var(--fill, 0%) 100% no-repeat, var(--rule);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -8px;
  border: 0;
  background: var(--diamond) center / contain no-repeat;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 0;
  background: var(--diamond) center / contain no-repeat;
}
input[type="range"]:focus-visible { outline-offset: 4px; }

/* ---- Figure 2: erosion -------------------------------------------------------
   Two 20 x 20 bitmaps, one SVG unit per pixel, with the plus-shaped neighbourhood between
   them. At their full 200px a pixel is 10 screen pixels, so the squares (8) and the gaps
   (2) land on whole pixels. Empty pixels come from a pattern defined in the first bitmap. */
.erosion { margin-top: 1.5rem; }
.panels {
  display: grid;
  grid-template-columns: minmax(0, 200px) auto minmax(0, 200px);
  grid-template-areas:
    "label-before .        label-after"
    "before       operator after";
  gap: 0.75rem 1.5rem;
  justify-content: start;
  align-items: center;
  font-size: 0.8125rem;
  line-height: 1;
  color: var(--muted);
}
.panel-label.before { grid-area: label-before; }
.panel-label.after { grid-area: label-after; }
.bitmap.before { grid-area: before; }
.bitmap.after { grid-area: after; }
.bitmap { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.operator { grid-area: operator; display: grid; justify-items: center; gap: 0.75rem; }
.kernel { display: block; width: 30px; height: 30px; }
.arrow {
  display: block;
  width: 40px;
  height: 10px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.px-empty { fill: var(--pixel); }
.px-cell { fill: var(--series); }
.px-removed { fill: var(--series-faint); }
.px-kernel { fill: var(--ink); }

/* Drawing on the test image. */
.bitmap.editable { cursor: crosshair; touch-action: none; }
.bitmap.editable:focus-visible { outline-offset: 4px; }
.px-cursor { display: none; fill: none; stroke: var(--link); stroke-width: 0.12; }
.bitmap.editable:focus-visible .px-cursor { display: block; }
.figure-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  color: var(--muted);
}
.text-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--link);
  text-decoration: underline 1px var(--link-line);
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.text-button:hover { text-decoration-color: currentColor; }
.text-button:disabled { visibility: hidden; }

/* ---- Figure 3: growth curve -------------------------------------------------
   The SVG is stretched to the plot (preserveAspectRatio="none") and keeps its strokes at
   their set width (non-scaling-stroke). Ticks, the end value and the hover readout are HTML
   placed in percentages, so their text stays the same size on any screen. */
.chart { margin-top: 1.5rem; }
.plot {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  grid-template-rows: auto clamp(9.5rem, 34vw, 13rem) auto;
  font-size: 0.8125rem;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}
.y-title { grid-column: 2; margin-bottom: 0.75rem; }
.y-axis, .x-axis { position: relative; }
.y-axis { grid-row: 2; }
.y-axis span { position: absolute; right: 0.6rem; transform: translateY(50%); }
.x-axis { grid-column: 2; height: 1.75rem; }
.x-axis span { position: absolute; top: 0.6rem; transform: translateX(-50%); }
.x-axis span:last-child { transform: translateX(-100%); }

.plot-area { grid-row: 2; grid-column: 2; position: relative; touch-action: pan-y; }
.plot-area svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.grid { stroke: var(--rule); stroke-width: 1; }
.curve {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.grid, .curve { vector-effect: non-scaling-stroke; }

/* End-dot and probe: 8px, with a 2px ring in the paper colour where they sit on the line. */
.dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--series);
  box-shadow: 0 0 0 2px var(--paper);
  transform: translate(-50%, 50%);
}
.end-value {
  position: absolute;
  transform: translate(calc(-100% - 8px), -0.35rem);
  color: var(--ink);
  font-weight: 700;
}

/* Hover and keyboard readout (enhancement only: the table below has the same numbers). */
.cross { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); }
.cross, .probe, .readout { display: none; pointer-events: none; }
.plot-area.active .cross, .plot-area.active .probe, .plot-area.active .readout { display: block; }
.plot-area.active .dot.end, .plot-area.active .end-value { visibility: hidden; }
.readout {
  position: absolute;
  top: 0;
  margin-left: 10px;
  padding: 0.35rem 0.5rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  white-space: nowrap;
  line-height: 1.3;
}
.readout.flip { transform: translateX(calc(-100% - 20px)); }
.readout.low { top: auto; bottom: 0.5rem; }
.readout b { display: block; color: var(--ink); font-size: 0.9375rem; }
.plot-area:focus-visible { outline-offset: 6px; }

figcaption { margin-top: 0.75rem; font-size: 0.9375rem; color: var(--muted); }
.fig-label { color: var(--ink); font-weight: 700; }

details { margin-top: 0.5rem; font-size: 0.9375rem; color: var(--muted); }
summary { cursor: pointer; width: max-content; }
details[open] summary { margin-bottom: 0.5rem; }
.data { border-collapse: collapse; font-variant-numeric: lining-nums tabular-nums; }
.data th, .data td { padding: 0.15rem 1.5rem 0.15rem 0; text-align: right; }
.data .left { text-align: left; }
.data th { font-weight: 400; font-style: italic; border-bottom: 1px solid var(--rule); }
.data td { color: var(--ink); }
details p { margin-top: 0.5rem; }

/* ---- Footer -------------------------------------------------------------- */
.colophon {
  margin-top: 5.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ---- Not-found page ------------------------------------------------------ */
.site-header { margin-bottom: 4.5rem; }
.notfound h1 { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.5rem); line-height: 1.15; }
.notfound p { margin-top: 1rem; max-width: var(--measure); }
.home-link { font-weight: 700; color: var(--ink); text-decoration: none; }
.home-link:hover { text-decoration: underline 1px; text-underline-offset: 0.2em; }

/* ---- Narrow screens: dates move above titles, the timeline moves to the edge -- */
@media (max-width: 40rem) {
  body { font-size: 1.0625rem; }
  .page { padding: 3rem 1rem 2rem; }
  .masthead { grid-template-columns: minmax(0, 1fr); margin-bottom: 3.5rem; }
  .name { margin-bottom: 1.5rem; }
  .contact { display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin-bottom: 1.5rem; font-size: inherit; }
  .intro { font-size: 1.125rem; }
  .site-header { margin-bottom: 3rem; }
  section + section { margin-top: 3.5rem; }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry + .entry { margin-top: 2rem; }
  .when { margin-bottom: 0.2rem; }
  .subhead { margin-left: 0; }
  .x-axis .minor { display: none; }   /* every 24 h instead of every 12 h */
  .panels { column-gap: 0.75rem; }
  .grades td { padding-left: 1.5rem; }
  .ct-panels { column-gap: 0.5rem; }
  .ct-controls { gap: 0.75rem 1.25rem; }
  .ct-angles { flex: 1 1 100%; }
  .ct-angles input[type="range"] { flex: 1; width: auto; }
  .ct-error { margin-left: 0; }
  .timeline {
    --marker-x: 0px;
    --marker-y: calc(0.9375rem * 1.6 / 2 - 8px);   /* centred on the date line */
  }
  .timeline .entry { padding-left: 1.75rem; }
  .colophon { margin-top: 4rem; }
}

/* ---- Print: the PDF is the printable CV, this keeps a printout tidy -------- */
@media print {
  :root {
    --paper: #fff; --ink: #000; --muted: #444; --rule: #bbb; --link: #000;
    --link-line: transparent; --series: #000; --pixel: #e6e6e6; --series-faint: #aaa;
  }
  body { font-size: 10.5pt; }
  .page { max-width: none; padding: 0; }
  details, .readout, .cross, .probe, .ct, .figure-tools { display: none !important; }
  .name::before, .name h1, .name .role, .contact, .intro { animation: none; }
}
