/* adalsteinsson.com base chassis. Tokens and components are specified in DESIGN.md. */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  --page: #e6e2dc;
  --paper: #ffffff;
  --panel: #f5f0ea;
  --ink: #16120f;
  --muted: #675a53;
  --line: #e2d6cc;
  --line-2: #efe6de;
  --copper: #b0562b;
  --copper-dk: #8d4320;
  --copper-l: #d1804d;
  --t-copper: #fbeee5;
  --steel: #2b4f63;
  --steel-l: #4a7d96;
  --t-steel: #e9f0f4;
  --olive: #5d6e43;
  --t-olive: #eef1e6;
  --sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --shadow: 0 28px 74px rgba(45, 28, 16, 0.16);
  --shadow-soft: 0 14px 34px rgba(45, 28, 16, 0.1);
  --shadow-border: 0 0 0 1px rgba(45, 28, 16, 0.055), 0 1px 2px -1px rgba(45, 28, 16, 0.06), 0 8px 24px -18px rgba(45, 28, 16, 0.2);
  --pad: clamp(20px, 4vw, 56px);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1100px 640px at 78% -8%, rgba(176, 86, 43, 0.16), transparent 62%),
    radial-gradient(900px 560px at 6% 4%, rgba(43, 79, 99, 0.1), transparent 62%),
    var(--page);
  background-attachment: fixed;
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-wrap: balance;
}

p { margin: 0 0 16px; text-wrap: pretty; }

a { color: inherit; }

img, video { display: block; max-width: 100%; }

::selection { background: var(--copper); color: #fff; }

:focus-visible { outline: 2.5px solid var(--copper); outline-offset: 3px; }

/* ---------- sheet ---------- */

.shell {
  max-width: 1280px;
  margin: clamp(12px, 2.2vw, 30px) auto;
  background: var(--paper);
  border-radius: clamp(18px, 2.4vw, 32px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.shell.entry { max-width: 1040px; }

.inner { padding-inline: var(--pad); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--copper);
  margin: 0 0 12px;
}

/* ---------- top bar ---------- */

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px var(--pad);
  border-bottom: 1px solid var(--line-2);
}

.brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}

.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; font-size: 14.5px; font-weight: 600; }
.nav a { text-decoration: none; color: var(--muted); transition: color 0.16s; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--copper); }
.nav-toggle { display: none; min-height: 40px; border: 0; background: var(--paper); border-radius: 10px; padding: var(--space-2) var(--space-3); box-shadow: var(--shadow-border); font: inherit; cursor: pointer; }
@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; align-items: center; gap: 6px; }
  .nav[data-open="false"] { display: none; }
  .nav { width: 100%; flex-direction: column; align-items: flex-start; gap: 10px; }
  .head { flex-wrap: wrap; }
}

/* ---------- metadata chips ---------- */

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tag-row a, .tag-row span {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  text-decoration: none;
}
.tag-row a:hover { color: var(--ink); border-color: #d2c2b6; }
.tag-row a[aria-current="true"], .tag-row .active {
  background: var(--t-copper);
  color: var(--copper-dk);
  border-color: var(--copper);
}
/* Structural markers: steel = belongs to an arc, olive = a gallery (priority-ordered, not chronological). */
.tag-row .arc { background: var(--t-steel); color: var(--steel); border-color: #d3dee6; }
.tag-row .type-gallery { background: var(--t-olive); color: var(--olive); border-color: #dfe5d3; }

/* ---------- entry meta line ---------- */

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  margin: 14px 0 0;
}
.entry-meta time { font-variant-numeric: tabular-nums; }

/* ---------- prose ---------- */

.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0 0 18px; }
.prose pre { margin: 0 0 18px; }
.prose h2 { font-size: 22px; margin: var(--space-8) 0 var(--space-3); }
.prose h3 { font-size: 18px; margin: var(--space-6) 0 var(--space-2); }
.prose a { color: var(--copper); font-weight: 600; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.prose a:hover { color: var(--copper-dk); }
.prose blockquote { border-left: 3px solid var(--line); padding-left: var(--space-4); color: var(--muted); }
.prose pre { overflow-x: auto; background: var(--panel); border-radius: 10px; padding: var(--space-4); font-family: var(--mono); font-size: 13.5px; }
.prose code { font-family: var(--mono); font-size: 0.92em; background: var(--panel); padding: 0.1em 0.4em; border-radius: 5px; }
.prose pre code { background: none; padding: 0; }
/* A markdown image with title="thumb" becomes a floated figure; click opens the lightbox. */
.prose figure.thumb {
  float: right;
  width: min(34%, 320px);
  margin: 4px 0 20px 24px;
  cursor: zoom-in;
}
.prose figure.thumb img { display: block; width: 100%; height: auto; border-radius: 10px; box-shadow: var(--shadow-soft); margin: 0; }
.prose figure.thumb figcaption { margin-top: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
@media (max-width: 640px) {
  .prose figure.thumb { float: none; width: 100%; margin-inline: 0; }
}

/* ---------- lightbox ---------- */

dialog.lightbox {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(92vw, 1100px);
  max-height: 88vh;
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.lightbox::backdrop { background: rgba(22, 18, 15, 0.62); }
dialog.lightbox.is-max { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
.lightbox-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line-2);
}
.lightbox-name {
  margin: 6px 0;
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.lightbox-controls { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.lightbox-controls a.lightbox-download {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--copper);
  text-decoration: none;
  cursor: pointer;
}
.lightbox-controls a.lightbox-download:hover { color: var(--copper-dk); }
.lightbox-controls button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--copper-dk);
  cursor: pointer;
}
.lightbox-controls button:hover { border-color: #d2c2b6; }
.lightbox-controls svg { display: block; width: 14px; height: 14px; }
dialog.lightbox:not(.is-max) .icon-restore { display: none; }
dialog.lightbox.is-max .icon-max { display: none; }
.lightbox-stage {
  max-height: calc(88vh - 53px);
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--panel);
}
dialog.lightbox.is-max .lightbox-stage { max-height: calc(100vh - 53px); }
.lightbox-stage img { display: block; max-width: 100%; height: auto; }

/* ---------- listing (chronological entries) ---------- */

.listing { display: grid; gap: var(--space-4); }
.card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: var(--space-6);
  border-radius: 16px;
  background: var(--paper);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s, box-shadow 0.16s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -26px rgba(45, 28, 16, 0.35); }
.card h2 { font-size: 19px; margin-bottom: 6px; letter-spacing: -0.025em; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.card .entry-meta { margin-top: 10px; }
/* A gallery card carries its olive marker on the card itself, not only in the tag row, so the different ordering reads before a click. */
.card.type-gallery { border-left: 3px solid var(--olive); }

/* ---------- gallery ---------- */

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-4); }
.gallery figure { margin: 0; border-radius: 14px; overflow: hidden; background: var(--panel); box-shadow: var(--shadow-soft); }
.gallery img, .gallery video { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; }
.gallery figcaption { padding: 10px 14px; font-size: 13px; color: var(--muted); }
.gallery.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

/* ---------- states ---------- */

.state {
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--muted);
}
.state a { color: var(--copper); font-weight: 600; }

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

footer.inner { padding-block: 24px 32px; font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line-2); }
footer .inner-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }

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

@media print {
  body { background: #fff; }
  .shell { box-shadow: none; border-radius: 0; max-width: none; margin: 0; }
  .head, .nav, .nav-toggle, footer { display: none; }
  .prose a { color: var(--ink); text-decoration: underline; }
  .copper, .eyebrow { color: #000; }
}
