/* ==================================================================
   themetalevel.org
   A quiet, typographic layout. One column, generous air, one accent.
   ================================================================== */

:root {
  --paper:      #fbfaf7;
  --paper-sunk: #f3f1ec;
  --ink:        #17191b;
  --ink-soft:   #3d4245;
  --muted:      #71767a;
  --rule:       #e3dfd6;
  --accent:     #0d6b63;
  --accent-lit: #0a5852;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono:  ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono", Menlo, Consolas, monospace;

  /* The shell is wide enough for panels; prose is constrained inside it
     and left-aligned, so body text always starts under the wordmark. */
  --measure: 58rem;
  --prose:   36rem;
  --gutter:  clamp(1.25rem, 5vw, 2.5rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #131517;
    --paper-sunk: #1a1d1f;
    --ink:        #e9e7e2;
    --ink-soft:   #c8c6c1;
    --muted:      #8b9094;
    --rule:       #292d30;
    --accent:     #63c6ba;
    --accent-lit: #8ad9cf;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* --- shell -------------------------------------------------------- */

.shell {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Reading column. Left-aligned inside the shell so that prose, the
   wordmark and section labels all share one left edge. */
.prose { max-width: var(--prose); }

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: var(--gutter);
  top: 0.75rem;
  z-index: 10;
  background: var(--paper);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
}

/* --- masthead ----------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: clamp(2rem, 6vw, 3.5rem) 0;
}

.wordmark {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.wordmark:hover { color: var(--accent); }

.nav {
  display: flex;
  gap: 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover { color: var(--accent); }

.nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 1px;
}

/* --- headings and prose ------------------------------------------- */

main { padding-block: clamp(2.5rem, 8vw, 4.5rem) 0; }

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
  margin: 0;
}

h1 {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  letter-spacing: -0.015em;
}

h2 {
  font-size: 1.25rem;
  margin-block: 2.75rem 0.75rem;
}

h3 {
  font-size: 1.0625rem;
  margin-block: 2rem 0.5rem;
}

p, ul, ol, blockquote, figure, table, pre { margin-block: 0 1.25rem; }

p { text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover { color: var(--accent-lit); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.lede {
  font-size: 1.1875rem;
  color: var(--ink-soft);
  margin-block: 0 2rem;
  text-wrap: pretty;
}

.tagline {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-block: 0.5rem 0;
}

ul, ol { padding-inline-start: 1.25rem; }
li { margin-block: 0.35rem; }
li::marker { color: var(--muted); }

blockquote {
  margin-inline: 0;
  padding-inline-start: 1.25rem;
  border-inline-start: 2px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin-block: 3rem;
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--paper-sunk);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

pre code { background: none; padding: 0; font-size: inherit; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}

th {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

/* --- figures ------------------------------------------------------ */

figure {
  margin-block: 2rem;
  margin-inline: 0;
}

img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

figure img {
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
}

figcaption {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 0.6rem;
  text-wrap: pretty;
}

/* Let a wide figure use the space to the right of the prose column. */
@media (min-width: 62rem) {
  .figure-wide { width: calc(var(--prose) + 12rem); }
}

/* --- panels and cards --------------------------------------------- */

.panels {
  display: grid;
  gap: 1.5rem 1.25rem;
  grid-template-columns: 1fr;
}

@media (min-width: 44rem) {
  /* One big, three small: the lead card spans the row and lays its
     picture beside the text rather than stacking a slab on top. */
  .panels { grid-template-columns: repeat(3, 1fr); }
  .panels > .card--big { grid-column: 1 / -1; }
  .panels--even > .card--big { grid-column: auto; }

  .panels > .card--big a {
    flex-direction: row;
    align-items: stretch;
    gap: 1.75rem;
  }
  .panels > .card--big .card-art {
    flex: 0 0 54%;
    aspect-ratio: 16 / 10;
  }
  .panels > .card--big .card-body { flex: 1; justify-content: center; }
}

.card { margin: 0; }

.card a {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.card-art {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper-sunk);
}



.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.card a:hover .card-art img { transform: scale(1.02); }

/* Generated art, for anything posted without a picture. */
.card-art--generated {
  display: grid;
  place-items: center;
  border-color: transparent;
  background:
    repeating-linear-gradient(
      135deg,
      transparent 0 14px,
      rgb(255 255 255 / 0.07) 14px 28px
    ),
    linear-gradient(150deg, var(--art), color-mix(in oklab, var(--art) 62%, #000));
}

.card-art-label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.92);
  padding-inline: 1rem;
  text-align: center;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  text-wrap: pretty;
}

.card--big .card-title { font-size: 1.375rem; }

.card a:hover .card-title {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.card-note {
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.card--big .card-note { font-size: 1rem; }

.more {
  font-family: var(--mono);
  font-size: 0.75rem;
  margin-top: 1.25rem;
}

.more a { text-decoration: none; }
.more a:hover { text-decoration: underline; }

/* --- index listings ----------------------------------------------- */

.listing {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}

.listing > li {
  margin: 0;
  padding-block: 1.15rem;
  border-bottom: 1px solid var(--rule);
}

.entry-meta {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
}

.entry-title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
}

.entry-title a {
  color: var(--ink);
  text-decoration: none;
}

.entry-title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.entry-note {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
  text-wrap: pretty;
}

/* --- section label ------------------------------------------------ */

.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-block: 3.25rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

main > .label:first-child { margin-top: 0; }

/* --- doors (home: work / mafsworld / about) ----------------------- */

.doors {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

@media (min-width: 34rem) {
  .doors { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 52rem) {
  .doors { grid-template-columns: repeat(4, 1fr); }
}

.doors > li { margin: 0; }

.doors a {
  display: block;
  height: 100%;
  padding: 1.1rem 1.15rem;
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
}

.doors a:hover { background: var(--paper-sunk); }

.doors strong {
  display: block;
  font-weight: 600;
  font-size: 1rem;
}

.doors span {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-top: 0.15rem;
}

/* --- article header ----------------------------------------------- */

.article-head { margin-bottom: 2.25rem; }
.article-head .entry-meta { margin-bottom: 0.6rem; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.tags li { margin: 0; }

.tags span {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 0.15rem 0.55rem;
}

.callout {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.15rem;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.callout > :last-child { margin-bottom: 0; }
.callout strong { color: var(--ink); }

/* --- maths -------------------------------------------------------- */

.maths-block {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 0.6rem;
  margin-block: 1.5rem;
}

/* Wide formulae borrow the empty space beside the reading column. */
@media (min-width: 62rem) {
  .maths-block { width: calc(var(--prose) + 10rem); }
}

.katex { font-size: 1.05em; }

.math-error {
  color: #b3261e;
  background: none;
}

/* --- footer ------------------------------------------------------- */

.footer {
  margin-top: clamp(4rem, 12vw, 7rem);
  padding-block: 1.5rem clamp(2.5rem, 8vw, 4rem);
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
}

.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* --- print -------------------------------------------------------- */

@media print {
  .nav, .footer, .skip { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; }
}

/* --- named rows on a project page ---------------------------------
   A project page groups its notes into rows it names itself. The row
   scrolls sideways when it holds more than fits, so a long row never
   makes the whole page scroll. */

.panels--row {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.panels--row > .card {
  flex: 0 0 min(17rem, 80%);
  scroll-snap-align: start;
}

/* --- the hero link ------------------------------------------------
   One picture that is the whole point of a page: the way in to the
   main document, sized so it cannot be mistaken for a card. */

.hero-link {
  display: block;
  margin: 0 0 2rem;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper);
}

.hero-link img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.hero-link:hover img { transform: scale(1.02); }

.hero-link-body {
  display: block;
  padding: 1.25rem 1.5rem 1.5rem;
}

.hero-link-kicker {
  display: block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.hero-link-title {
  display: block;
  font-size: 1.625rem;
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.hero-link:hover .hero-link-title { color: var(--accent); }

.hero-link-note {
  display: block;
  color: var(--muted);
  max-width: 46ch;
}

@media (min-width: 44rem) {
  .hero-link img { aspect-ratio: 21 / 9; }
  .hero-link-title { font-size: 2rem; }
}
