/* hanneszetterblom.com - single stylesheet. No inline styles anywhere (CSP). */

/* 1. Tokens. Light by default. Dark by OS preference unless data-theme="light".
      Forced dark with data-theme="dark". */
:root {
  color-scheme: light;
  --bg: #F3F4F2;
  --panel: #FFFFFF;
  --ink: #16191D;
  --ink-2: #55606B;
  --ink-3: #66707A; /* DL-007: spec value #7C868F failed AA */
  --rule: #D6D9D4;
  --accent: #8A5209; /* DL-009: instrument amber */
  --sans: "Familjen Grotesk", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; /* DL-008 */
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --measure: 42rem;
  --measure-note: 65ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121314;
    --panel: #1A1C1E;
    --ink: #E7EAED;
    --ink-2: #B3BBC3;
    --ink-3: #7F8993;
    --rule: #2B2E31;
    --accent: #E3A94E;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121314;
  --panel: #1A1C1E;
  --ink: #E7EAED;
  --ink-2: #B3BBC3;
  --ink-3: #7F8993;
  --rule: #2B2E31;
  --accent: #E3A94E;
}

/* 2. Type scale. Root stays 16px so rem sizes hold; body text is 18px, 17px under 560px (DL-016). */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

h1 {
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 600;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  font-weight: 600;
}

h3 {
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 600;
}

@media (max-width: 559.98px) {
  body {
    font-size: 1.0625rem;
  }
}

/* 3. Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  padding: 0 1rem;
  overflow-wrap: break-word;
}

p {
  margin: 0 0 1rem;
}

h1,
h2,
h3 {
  margin: 0 0 0.75rem;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--ink-3);
}

a:hover {
  text-decoration-color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

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

.skip {
  position: absolute;
  top: -5rem;
  left: 1rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--ink);
}

.skip:focus {
  top: 0.5rem;
}

/* 4. One centered column, left-aligned text (DL-012). */
.site-header,
main,
.site-footer {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}

/* 5. Header */
.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 1.25rem 1.5rem;
  align-items: start;
  padding-top: 3rem;
}

.site-header h1 {
  margin: 0;
}

.lede {
  margin: 0.75rem 0 0;
  font-size: 1.1875rem;
  line-height: 1.45;
}

.photo {
  display: block;
  width: 96px;
  height: 96px;
  background: var(--panel);
  border: 1px solid var(--rule);
  object-fit: cover;
}

.site-header nav,
.site-name {
  grid-column: 1 / -1;
}

.site-header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
}

.site-header nav a {
  display: inline-block;
  padding: 0.375rem 0;
  color: var(--ink-2);
}

.site-name {
  margin: 0;
  font-weight: 600;
}

@media (max-width: 599.98px) {
  .site-header {
    padding-top: 2rem;
  }

  /* The sentence gets the full width under the name and the photo. */
  .header-text {
    display: contents;
  }

  .site-header h1 {
    grid-area: 1 / 1;
    align-self: center;
  }

  .photo {
    grid-area: 1 / 2;
  }

  .lede {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 0;
  }

  .site-header nav {
    grid-row: 3;
  }
}

/* 6. Right now readout (DL-010): one row per value, label and source left, value right */
#right-now {
  margin-top: 2rem;
}

.stats {
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

/* Markup order is label, value, source. The grid puts the source under the label and the value to the right. */
.stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1rem;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
}

.stat dt {
  grid-area: 1 / 1;
}

.stat dd {
  margin: 0;
}

.stat .source {
  grid-area: 2 / 1;
  color: var(--ink-3);
  font-size: 0.875rem;
}

.stat .value {
  grid-area: 1 / 2 / 3 / 3;
  font-size: 1.9rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.stat .value a {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* The hero row: the one display-size element, stacked as value, label, source. */
.stat-hero {
  grid-template-columns: minmax(0, 1fr);
  padding: 0.25rem 0 1rem;
  border-top: 0;
}

.stat-hero .value {
  grid-area: 1 / 1;
  font-size: 3.5rem;
  line-height: 1.05;
  text-align: left;
}

.stat-hero dt {
  grid-area: 2 / 1;
  margin-top: 0.375rem;
}

.stat-hero .source {
  grid-area: 3 / 1;
}

.stat .year {
  color: var(--ink-3);
  font-size: 0.875rem;
  font-weight: 400;
}

@media (max-width: 559.98px) {
  /* The source line gets the full row width so it stays on one line. */
  .stat {
    align-items: baseline;
  }

  .stat .source {
    grid-column: 1 / -1;
  }

  .stat .value {
    grid-area: 1 / 2;
    font-size: 1.6rem;
  }

  .stat-hero .value {
    grid-area: 1 / 1;
    font-size: 2.5rem;
  }
}

/* Heatmap: one column per week, drawn by script.js from daily_hours. Cells are the accent at five opacities. */
.hm-figure {
  margin: 0 0 1.5rem;
}

.heatmap {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
}

.hm-cell {
  fill: var(--accent);
}

.hm-label {
  fill: var(--ink-3);
  font-size: 11px;
}

.hm-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0.5rem 0 0;
  color: var(--ink-3);
  font-size: 0.875rem;
}

.hm-legend[hidden] {
  display: none;
}

.hm-sw {
  flex: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
}

.hm-sw-1 { opacity: 0.12; }
.hm-sw-2 { opacity: 0.3; }
.hm-sw-3 { opacity: 0.5; }
.hm-sw-4 { opacity: 0.75; }
.hm-sw-5 { opacity: 1; }

.meta {
  color: var(--ink-3);
  font-size: 0.875rem;
}

#right-now .meta {
  margin: 0.625rem 0 1rem;
}

/* 7. Sections: a 1px rule and whitespace */
main > section,
article + article,
.bio {
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
}

#right-now {
  padding-top: 0;
  border-top: 0;
}

main > section > :last-child,
article > :last-child {
  margin-bottom: 0;
}

/* 8. Figures and diagrams. Shapes are stroked with currentColor and filled with the panel color only. */
figure {
  margin: 1.5rem 0;
}

figure svg {
  display: block;
  width: 100%;
  max-width: 24.5rem;
  height: auto;
  color: var(--ink);
  font-family: inherit;
}

figcaption {
  margin-top: 0.625rem;
  color: var(--ink-2);
  font-size: 0.875rem;
}

.dg-box {
  fill: var(--panel);
  stroke: currentColor;
  stroke-width: 1.25;
}

.dg-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
}

.dg-t,
.dg-s {
  text-anchor: middle;
}

.dg-t {
  fill: currentColor;
  font-size: 14px;
  font-weight: 500;
}

.dg-s {
  fill: var(--ink-2);
  font-size: 12.5px;
}

/* 9. Lists */
.outcomes {
  margin: 0 0 1rem;
  padding-left: 1.125rem;
}

.outcomes li {
  margin-bottom: 0.375rem;
}

.outcomes li::marker {
  color: var(--ink-3);
}

.outcomes li.todo {
  margin-left: -1.125rem;
  list-style: none;
}

/* The empty-string marker hides bullets and, unlike "none", keeps list semantics in Safari. */
.plain {
  margin: 0;
  padding: 0;
  list-style: none;
  list-style-type: "";
}

.plain li {
  margin-bottom: 0.625rem;
}

.h2-small {
  font-size: 1rem;
}

.dl-excerpt li {
  margin-bottom: 0.5rem;
}

.dl-id {
  color: var(--ink-2);
}

.facts {
  width: 100%;
  max-width: 32rem;
  margin: 0 0 1rem;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.facts th,
.facts td {
  padding: 0.5rem 0;
  border-top: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.facts tr:last-child th,
.facts tr:last-child td {
  border-bottom: 1px solid var(--rule);
}

.facts th {
  width: 50%;
  padding-right: 1rem;
  color: var(--ink-2);
  font-weight: 500;
}

/* 10. TODO blocks: visible until Hannes supplies the fact */
.todo {
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--ink-3);
  color: var(--ink-2);
  font-size: 0.875rem;
}

span.todo {
  display: inline-block;
}

/* 11. The single call to action: a plain underlined text link in the accent (DL-009) */
.cta {
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 500;
  text-decoration-color: currentColor;
}

/* 12. Bio and footer */
.bio {
  margin-bottom: 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.site-footer {
  margin-top: 2.5rem;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.875rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.links a {
  display: inline-block;
  padding: 0.375rem 0;
}

/* 13. Notes and 404 */
main > h1,
.note {
  margin-top: 2.5rem;
}

.note > h1,
.note > .meta {
  max-width: var(--measure);
}

.note-body {
  max-width: var(--measure-note);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
}

.note-body h2 {
  margin-top: 2rem;
  font-family: var(--sans);
}

.code-scroll {
  max-width: 100%;
  margin: 1.25rem 0;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--rule);
}

.code-scroll pre {
  margin: 0;
  padding: 0.875rem 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
}

.note-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1rem;
}

.note-list time {
  color: var(--ink-3);
  font-size: 0.875rem;
}
