/* Layout, rhythm, and theme — visual primitives come from vendored modest-ui;
   everything site-specific lives here and nowhere else.

   Foundation rules (the /notes discipline):
   1. Text faces flow from tokens only: --mdst-font-text for prose,
      --font-display for editorial headings. No font-family on elements.
   2. Vertical spacing comes from the flow rules, not per-element margins.
   3. Every colour is a light-dark() token pair; the scheme follows the
      system preference or the <theme-toggle> override.

   Palette: ink on warm paper, two accents from Marcus's own world —
   squiggle cyan (links, focus, the mark itself) and hotdog red (the
   emphasis word, the pen nib, hovers). --cyan/--hot are the loud graphic
   values; --cyan-text is the darker cut that clears WCAG AA at small
   sizes. All text pairs measured >= 4.5:1 on their backgrounds (AA). */

/* ---------- fonts (self-hosted, latin subsets, variable weight) ---------- */

@font-face {
  font-family: "Libre Baskerville";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/libre-baskerville.woff2") format("woff2");
}

@font-face {
  font-family: "Libre Baskerville";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/libre-baskerville-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/noto-sans.woff2") format("woff2");
}

/* ---------- tokens ---------- */

:root {
  /* Dark mode is PARKED, not removed (dark-on-transparent project images
     need art direction first): every colour below stays a light-dark()
     pair, but pinning color-scheme to light makes them all resolve light.
     To re-enable: change this to "light dark", then in templates/page.html
     restore <theme-toggle> + its script, the pre-paint boot script, and
     the media-keyed theme-color metas (copy all four from /notes). */
  color-scheme: light;

  --mdst-font-text: "Noto Sans", system-ui, sans-serif;
  --font-display: "Libre Baskerville", Georgia, serif;

  --paper: light-dark(#faf8f4, #1a1814);
  --ink: light-dark(#171512, #e9e4da);
  --muted: light-dark(#6b645b, #a39c8e);
  --cyan: light-dark(#0e9aa7, #1eb2c0);
  --cyan-text: light-dark(#0a6e78, #7fd4dc);
  --hot: light-dark(#c93a2f, #f07f76);

  --mdst-color-fg: var(--ink);
  --mdst-color-bg: var(--paper);
  --mdst-color-muted: var(--muted);
  --mdst-color-subtle: light-dark(#ece7de, #2a261f);
  --mdst-color-surface: light-dark(#f2eee6, #242019);
  --mdst-color-border: light-dark(#b9b1a3, #57503f);
  --mdst-color-focus: var(--cyan-text);
  --mdst-line-height: 1.6;

  /* Layout tokens for the ruled label system, used site-wide.
     --page-pad hugs the page edges (tight on mobile is right there);
     --section-gap is the vertical air between sections, which must NOT
     collapse with the viewport: 2.25rem on a phone up to 2.5rem. */
  --page-pad: clamp(1rem, 3vw, 2.5rem);
  --section-gap: clamp(2.25rem, 1.5rem + 2vw, 2.5rem);
  --rule: 1.5px solid var(--ink);
  --card-edge: 2px solid var(--ink);
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* Print in light mode whatever the screen theme is. */
@media print {
  :root,
  :root[data-theme="dark"] {
    color-scheme: light;
  }
}

/* ---------- base + flow ---------- */

body {
  background: var(--paper);
  color: var(--ink);
  margin: 0;
}

::selection {
  background: var(--hot);
  color: var(--paper);
}

:where(main, article, section) > * + * {
  margin-block-start: var(--mdst-space-md);
}

:where(main, article, section) > :where(h2, h3) {
  margin-block-start: var(--mdst-space-xl);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--cyan);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

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

/* ---------- site chrome: header + footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.4rem 1.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.site-header .wordmark,
.site-header nav a {
  text-decoration: none;
}

.site-header .wordmark {
  margin-inline-end: auto;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2.5vw, 1.6rem);
}

.site-header nav a {
  border-bottom: 2px solid var(--cyan);
  padding-bottom: 0.15rem;
}

.site-header nav a:hover {
  color: var(--hot);
  border-color: var(--hot);
}

/* Icon links are bare glyphs: no underline (symbols aren't text), same
   ink, same hover. The accessible name lives on the anchor. */
.site-header nav a.nav-icon {
  border-bottom: none;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
}

.site-header nav a.nav-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

/* The toggle is a bare glyph, not a modest-ui button: strip the library's
   button box (and its hover/focus fill) at every state. */
theme-toggle button,
theme-toggle button:hover,
theme-toggle button:focus-visible {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
}

theme-toggle button:hover {
  color: var(--hot);
}

/* Small screens: the inline nav gives way to a modest-ui drawer (a native
   dialog opened by invoker commands, no JS). Only the TRIGGER is hidden
   on wide screens: an open dialog is never hidden by CSS (a hidden-but-
   open modal traps interaction), it stays dismissable until closed. */
.menu-button,
.menu-button:hover,
.menu-button:focus-visible {
  display: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: none;
  border: none;
  border-bottom: 2px solid var(--cyan);
  padding: 0 0 0.15rem;
  cursor: pointer;
  color: inherit;
}

.menu-button:hover {
  border-color: var(--hot);
  color: var(--hot);
}

.mdst-drawer .drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.mdst-drawer .drawer-nav a {
  text-decoration: none;
  color: inherit;
  border-bottom: 2px solid var(--cyan);
  padding-bottom: 0.15rem;
  align-self: flex-start;
}

.mdst-drawer .drawer-nav a:hover {
  color: var(--hot);
  border-color: var(--hot);
}

.mdst-drawer .mdst-drawer-header {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .site-header nav.site-nav {
    display: none;
  }

  .site-header .menu-button {
    display: inline-block;
  }
}

.site-footer {
  padding: var(--mdst-space-lg) 1.6rem;
  color: var(--muted);
  text-align: center;
}

/* The mark signs off every page, small and quiet. */
.footer-squiggle svg {
  display: block;
  margin: 1rem auto;
  width: 3.2rem;
  height: auto;
  color: var(--muted);
}

/* ---------- marcusmail ---------- */

.marcusmail-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.marcusmail-form input[type="email"] {
  flex: 1 1 14rem;
}

.form-note {
  color: var(--cyan-text);
  font-weight: 500;
}

.form-note.error {
  color: var(--hot);
}

/* ---------- homepage: the technical label ---------- */

/* The hero is a ruled spec-sheet card. On the homepage the site header is
   the card's first row: the card border wraps header + hero together
   (header carries the outer top edge, the hero carries the rest). */

.home .site-header {
  margin: var(--page-pad) var(--page-pad) 0;
  border: var(--card-edge);
  border-bottom: var(--rule);
  padding: 0.9rem 1.2rem;
}

.hero {
  margin: 0 var(--page-pad);
  border: var(--card-edge);
  border-top: none;
}

.hero .row + .row {
  border-top: var(--rule);
  margin: 0;
}

.hero .statement {
  padding: clamp(1.6rem, 4vw, 3.2rem) 1.2rem;
}

.hero h1 {
  font-weight: 400;
  font-size: clamp(1.9rem, 4.4vw, 3.6rem);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0;
  max-width: 24ch;
  text-wrap: balance;
}

.hero .figure {
  display: grid;
  grid-template-columns: minmax(11rem, 0.28fr) 1fr;
}

.fig-caption {
  border-right: var(--rule);
  padding: 1.1rem 1.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  justify-content: space-between;
}

.fig-sub {
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.14em;
}

.fig-art {
  display: block;
  padding: clamp(1.2rem, 5vw, 5.4rem);
  /* the inlined logo's paths use fill="currentColor" */
}

.fig-art svg {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 60%;
}

/* Click the mark, it wiggles (components/wiggle-mark.js adds .wigglable
   when it takes over; without JS or with reduced motion, nothing). */
.fig-art.wigglable {
  cursor: pointer;
}

.fig-art.wiggling svg {
  animation: wiggle 0.75s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes wiggle {
  15% {
    transform: rotate(-2.2deg);
  }

  35% {
    transform: rotate(2deg);
  }

  55% {
    transform: rotate(-1.4deg);
  }

  75% {
    transform: rotate(0.8deg);
  }
}

/* Explicit column counts per range (4 → 2x2 → 1), never auto-fit: a
   fitted count like 3 orphans the fourth field onto its own row. */
.hero .fields {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
}

.field {
  padding: 1rem 1.2rem;
  border-left: var(--rule);
}

.field:first-child {
  border-left: none;
}

.field dt {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.field dd {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.field dd.hot {
  color: var(--hot);
}

@media (min-width: 721px) and (max-width: 980px) {
  .hero .fields {
    grid-template-columns: repeat(2, 1fr);
  }

  .field {
    border-left: none;
  }

  .field:nth-child(even) {
    border-left: var(--rule);
  }

  .field:nth-child(n + 3) {
    border-top: var(--rule);
  }
}

@media (max-width: 720px) {
  .site-header,
  .site-header nav {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .hero .figure {
    grid-template-columns: 1fr;
  }

  .fig-caption {
    border-right: none;
    border-bottom: var(--rule);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    row-gap: 0.5rem;
  }

  .hero .fields {
    grid-template-columns: 1fr;
  }

  .field {
    border-left: none;
    border-top: var(--rule);
  }

  .hero .fields .field:first-child {
    border-top: none;
  }
}

/* ---------- homepage: flagship products ---------- */

.products {
  margin: var(--section-gap) var(--page-pad) 0;
}

.creations-frame {
  border: var(--card-edge);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.creation {
  padding: clamp(1.4rem, 3vw, 2.2rem);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.creation + .creation {
  border-left: var(--rule);
}

.creation-icon {
  width: 3.6rem;
  height: 3.6rem;
  margin-bottom: 0.5rem;
}

.creation h3 {
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 1.65rem);
  font-weight: 400;
}

.creation h3 a {
  text-decoration: none;
}

.creation h3 a:hover {
  color: var(--hot);
}

.creation-line {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
}

.creation-proof {
  margin: auto 0 0;
  padding-top: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 860px) {
  .creations-frame {
    grid-template-columns: 1fr;
  }

  .creation + .creation {
    border-left: none;
    border-top: var(--rule);
  }
}

/* ---------- homepage: the junk drawer ---------- */

/* The old site's terminal, ported as-was: Mac window chrome, green
   phosphor text. Fixed colours (a terminal is dark whatever the theme). */

/* The terminal is a real window sitting on a full-bleed strip of the old
   homepage's fixed squiggle wallpaper: the strip gives the window a desk
   to sit on (instead of floating in paper), and scrolling over the fixed
   pattern is the old site's little parallax moment. */
#tools {
  margin: var(--section-gap) 0 0;
  /* Vertical inner spacing matches the section rhythm; horizontal
     stays on the page grid so the terminal aligns with the sections
     above and below. */
  padding: var(--section-gap) var(--page-pad);
  border-block: 2px solid var(--ink);
  /* A darker cut of the paper (the surface token), not stark white. */
  background-color: var(--mdst-color-surface);
  display: grid;
  gap: var(--page-pad);
  justify-items: center;
}

/* The caption beside the window: bare text in the card's fig-caption
   voice (no box), so the strip has a name without competing furniture. */
.tools-note {
  max-width: 700px;
  width: 100%;
  align-self: center;
}

/* Shared section-header voice, matching the card's fig captions. */
.section-eyebrow {
  margin: 0 0 0.6rem;
  font-family: var(--mdst-font-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 26rem;
}

@media (min-width: 900px) {
  #tools {
    grid-template-columns: minmax(16rem, 24rem) minmax(0, 700px);
    justify-content: center;
    gap: clamp(1.6rem, 4vw, 4rem);
  }

  .tools-note {
    width: auto;
  }
}

.terminal {
  margin-top: 0;
  border-radius: 8px;
  max-width: 700px;
  width: 100%;
  font-family: var(--mdst-font-mono, monospace);
  overflow: hidden;
}

.terminal-header {
  background: #2d2d2d;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  display: flex;
}

.terminal-dot {
  border-radius: 50%;
  width: 12px;
  height: 12px;
}

.terminal-dot.red {
  background: #ff5f56;
}

.terminal-dot.yellow {
  background: #ffbd2e;
}

.terminal-dot.green {
  background: #27ca40;
}

.terminal-title {
  color: #a8a8a8;
  margin-left: 8px;
  font-size: 13px;
}

.terminal-body {
  color: #0f0;
  background: #1a1a1a;
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
}

.terminal-prompt {
  color: #0f0;
  margin: 0 0 16px;
}

.terminal-prompt:last-child {
  margin-top: 16px;
  margin-bottom: 0;
}

.terminal-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.terminal-list li {
  margin: 0;
  padding: 0;
}

.terminal-list li a {
  border-radius: 4px;
  margin: 2px -12px 0;
  padding: 8px 12px;
  text-decoration: none;
  transition: background 0.15s;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.terminal-list li a:hover {
  background: #00ff001a;
}

.terminal-file {
  color: #0f0;
  min-width: 180px;
  font-weight: 500;
}

.terminal-file::before {
  content: "./";
  color: #949494;
}

.terminal-desc {
  color: #949494;
  font-size: 13px;
  line-height: 1;
}

.terminal-cursor {
  animation: 1s step-end infinite blink;
}

@keyframes blink {
  0%,
  to {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

@media (max-width: 620px) {
  .terminal-list li a {
    flex-direction: column;
    gap: 4px;
    align-items: unset;
  }

  .terminal-file {
    min-width: auto;
  }

  .terminal-desc {
    padding-left: 1.1rem;
  }
}

/* ---------- homepage: selected work (the index) ---------- */

.work,
.brands {
  margin: var(--section-gap) var(--page-pad) 0;
}

.section-head {
  margin-bottom: 1.4rem;
}

/* Two explicit column lists: every row rule runs edge to edge, meeting
   the centre rule (border-left on the second list) and the outer edges. */
.work-index {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: var(--rule);
}

.work-index ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.work-index ul + ul {
  border-left: var(--rule);
}

.work-index li {
  border-bottom: var(--rule);
}

.work-index a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem clamp(1rem, 2.5vw, 2rem);
  text-decoration: none;
}

.wi-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.work-index a:hover .wi-title {
  color: var(--hot);
}

.wi-field {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: right;
}

@media (max-width: 860px) {
  .work-index {
    grid-template-columns: 1fr;
  }

  .work-index ul + ul {
    border-left: none;
  }

  .work-index a {
    padding-inline: 0.2rem;
  }
}

/* ---------- homepage: brand wall ---------- */

/* A ruled compartment grid in the card's language: 2px frame, 1.5px
   rules between cells. Cells carry right+bottom rules; the list is
   nudged one rule-width past the frame so edge rules tuck under it,
   whatever column count the width produces. */
.brand-wall-frame {
  border: var(--card-edge);
  overflow: hidden;
}

/* Square compartments, borders touching, at column counts that divide
   the 18 logos evenly (6 / 3 / 2), so every row is always complete and
   the wall scales as one piece. */
.brand-wall {
  margin: 0 -1.5px -1.5px 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}

.brand-wall li {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: var(--rule);
  border-bottom: var(--rule);
  margin-bottom: 0;
}

/* Marks are normalised to currentColor (ink); each carries its width as
   a percentage of the cell (data/brands.js), so the optical balance
   holds at every size. Hover lifts the mark slightly. */
.brand-wall img {
  height: auto;
  max-width: 72%;
  max-height: 60%;
  opacity: 0.82;
  transition: opacity 0.15s ease;
}

.brand-wall li:hover img {
  opacity: 1;
}

@media (max-width: 560px) {
  .brand-wall {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- project pages ---------- */

.project main {
  max-width: 46rem;
  margin-inline: auto;
  padding: var(--mdst-space-lg) var(--mdst-space-md) var(--mdst-space-xl);
}

.project main img {
  max-width: 100%;
  height: auto;
  border-radius: var(--mdst-radius);
}

/* Embedded demos (banner iframes, video embeds): kill the browser's
   default inset border; size comes from their width/height attributes. */
.project main iframe {
  border: 0;
  display: block;
  max-width: 100%;
}

.project .kicker {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan-text);
  margin: 0;
}

.project .kicker + h1 {
  margin-block-start: var(--mdst-space-xs);
}
