/* =============================================================
   4-BLOCKS — FRAMEWORK (reusable as-is)
   Styles for the page sections in /blocks. Each block is one
   <section> (or <header>/<footer>) with two classes: "block" and
   its own name, e.g. class="block block-hero".
   Blocks can go in any order on a page.

   Variants: some blocks look different with data-variant="...".
   Variants are how two sites built from the same blocks end up
   looking unlike each other.
   ============================================================= */

/* Every block gets the same vertical breathing room. */
.block {
  padding-block: var(--space-6);
}

/* ---------- block-header ---------- */
.block-header {
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--color-line);
}
.block-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
/* Name left, links right while they fit on one row. When the header
   is narrower than --header-row, each takes a full line and both are
   centred. min-width flips between 0 and 100% with no media query.
   --header-row must be at least the width the name and links need
   side by side (about 41rem here); raise it if the nav grows.     */
.block-header .wrap > * {
  --header-row: 42rem;
  min-width: clamp(0px, (var(--header-row) - 100%) * 999, 100%);
  text-align: center;
}
.block-header nav .cluster {
  justify-content: center;
}
/* The site name, as text or as a logo image. */
.block-header__logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--size-h3);
  line-height: 1;
  color: var(--color-text);
  text-decoration: none;
}
.block-header__logo:hover {
  color: var(--color-accent);
}
.block-header__logo img {
  width: 11rem;
}
/* Rows of wrapped links sit close; touch screens already give each
   link a 44px tap height (2-base.css), so no extra row gap is needed. */
.block-header nav .cluster {
  row-gap: 0;
}
.block-header nav a {
  color: var(--color-text);
  text-decoration: none;
}
.block-header nav a:hover {
  color: var(--color-accent);
}

/* ---------- block-hero ----------
   Variants (combine with spaces, e.g. data-variant="centered red"):
   (none)       text and image side by side
   centered     one centred column, image on top
   red          accent background with light text
   To make the header + hero fill exactly the first screen, wrap
   both in <div class="first-screen"> (see index.html).            */
.block-hero h1 {
  max-width: 18ch;
}
/* Optional: a logo image inside the h1 instead of text. Large, but
   capped by screen height so it still fits the first screen.      */
.block-hero__logo {
  display: block;
  width: min(100%, 26rem, 45svh);
  margin-inline: auto; /* centred in its column */
}
.block-hero h1:has(> .block-hero__logo) {
  max-width: none; /* the 18ch cap is for text headings, not a logo */
}
/* A label placed after the logo sits centred under it. */
.block-hero h1:has(> .block-hero__logo) ~ .label {
  text-align: center;
  margin-inline: auto;
}
/* Optional: the main nav inside the hero, centred under the logo.
   js/nav.js pins it to the top as a bar once it scrolls off screen
   (class "is-floating"), and keeps its space here so nothing jumps.
   Without the script it simply stays in the hero.                  */
.block-hero__nav {
  min-height: var(--nav-space, auto);
  container-type: inline-size; /* lets the nav size to its column */
}
/* Text and gaps shrink a little when the nav's column is narrow, so
   the links fit one row on most phones and in the two-column hero.
   (cqi = 1% of the column's width; the vw lines are for old browsers.) */
.site-nav {
  font-size: clamp(var(--size-small), 4vw, var(--size-body));
  font-size: clamp(var(--size-small), 4.5cqi, var(--size-body));
}
.site-nav .cluster {
  justify-content: center;
  row-gap: 0;
  column-gap: clamp(var(--space-2), 3vw, var(--space-4));
  column-gap: clamp(var(--space-2), 3cqi, var(--space-4));
}
.site-nav a {
  color: var(--color-text);
  text-decoration: none;
}
.site-nav.is-floating {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 5;
  /* Background runs edge to edge; the contents line up with .wrap. */
  padding-block: var(--space-2);
  padding-inline: max(var(--gutter), (100% - var(--page-max)) / 2);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-line);
}
/* Optional site name inside the nav: hidden in the hero (the logo is
   right there), shown in the pinned bar. Name left and links right
   while they fit; narrower than --bar-row, both centred on their own
   lines (min-width flips between 0 and 100%, no media query).      */
.site-nav__name {
  display: none;
}
.site-nav.is-floating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--space-4);
}
.site-nav.is-floating > * {
  --bar-row: 40rem;
  min-width: clamp(0px, (var(--bar-row) - 100%) * 999, 100%);
  text-align: center;
}
.site-nav.is-floating .site-nav__name {
  display: block;
}
@media (prefers-reduced-motion: no-preference) {
  .site-nav.is-floating {
    animation: site-nav-drop 0.2s ease-out;
  }
}
@keyframes site-nav-drop {
  from { transform: translateY(-100%); }
}
.block-hero p {
  max-width: var(--text-max);
  color: var(--color-muted);
}
.block-hero[data-variant~="centered"] .split {
  flex-direction: column-reverse;
  text-align: center;
}
.first-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;   /* fallback for older browsers */
  min-height: 100svh;  /* the visible screen height on phones */
}
.first-screen > .block-hero {
  flex: 1;             /* hero takes whatever the header leaves */
  display: flex;
  align-items: center;
}
.block-hero[data-variant~="red"] {
  background: var(--color-accent);
  color: var(--color-on-accent);
}
.block-hero[data-variant~="red"] p {
  color: var(--color-on-accent);
}
.block-hero[data-variant~="centered"] h1,
.block-hero[data-variant~="centered"] p {
  margin-inline: auto;
}

/* ---------- shared bits used inside blocks ---------- */

/* Small typewriter-style line above or below a heading. */
.label {
  font-family: var(--font-mono);
  font-size: var(--size-small);
  color: var(--color-muted);
}

/* Section heading, notebook style: a small numbered typewriter label
   ("01 /") over a thin rule, then large type. The numbers count up
   by themselves, one per heading, so there's nothing to type. */
main {
  counter-reset: section;
}
/* The count goes up on the section, not the heading: the audio block
   is a layout container, which would start its own count. */
.block:has(.block-heading) {
  counter-increment: section;
}
.block-heading {
  margin-bottom: var(--space-5);
  line-height: 1;
}
.block-heading::before {
  /* The "/ ''" part keeps screen readers from reading the number. */
  content: "0" counter(section) " /";
  content: "0" counter(section) " /" / "";
  display: block;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--size-small);
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-accent);
}

/* ---------- block-cards ----------
   A grid of cards: image (or video), label, title. A card is
   an <a class="card"> when it links out, or a <figure class="card">
   when it plays on the page.
   Variants:
   (none)                  square images (album covers)
   data-variant="wide"     16:9 images and videos                */
/* Square-image cards (4 albums): two rows of two in the middle
   widths, one row of four when there's room, so never three and
   one left over. Measured on the block's width, not the screen. */
/* .cards-box wraps only the list, never the heading: a container
   starts its own counter scope in some browsers, which broke the
   section numbers when it wrapped the whole block. */
.cards-box {
  container-type: inline-size;
}
@container (36rem <= width < 52rem) {
  .block-cards:not([data-variant~="wide"]) .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@container (width >= 52rem) {
  .block-cards:not([data-variant~="wide"]) .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
}
.card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  transition: opacity 0.2s;
}
.block-cards[data-variant~="wide"] .card img,
.card video {
  aspect-ratio: 16 / 9;
}
.card video {
  width: 100%;
  border-radius: var(--radius);
  background: var(--color-text);
}
.card:hover img {
  opacity: 0.85;
}
.card h3 {
  font-size: var(--size-h3);
}
.card:hover h3 {
  color: var(--color-accent);
}

/* ---------- block-gallery ----------
   A grid of photos with no captions. Set the size per photo with
   --min on the <ul>. Photos keep their own shape. */
.block-gallery img {
  width: 100%;
}

/* ---------- block-text ----------
   A heading and a few paragraphs, kept to a readable line length.
   Optional photo: wrap the .prose and an <img> in a .split. Text
   gets twice the room of the photo; the photo drops below the text
   when there isn't space. The photo keeps its own shape. */
.block-text .prose {
  max-width: var(--text-max);
}
.block-text .split {
  align-items: flex-start;
}
.block-text .split > .prose {
  flex: 2 1 20rem;
}
.block-text .split > img {
  flex: 1 1 14rem;
  max-width: 24rem;
  margin-inline-start: auto; /* line up with the page's right edge */
}

/* ---------- block-reveal ----------
   A line of accent-coloured text that opens to show more. Built on
   <details>, so it needs no JavaScript. The + turns into − when open. */
.block-reveal {
  padding-block: 0; /* a small line; sits close to the block above */
}
.block-reveal summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-accent);
  cursor: pointer;
  list-style: none;
}
.block-reveal summary:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.block-reveal summary::-webkit-details-marker {
  display: none;
}
.block-reveal summary::after {
  content: "+";
}
.block-reveal details[open] summary::after {
  content: "−";
}
.block-reveal .prose {
  max-width: var(--text-max);
  margin-top: var(--space-4);
  padding-left: var(--space-4);
  border-left: 4px solid var(--color-accent);
}
.block-reveal details[open] .prose {
  animation: reveal-in 0.25s ease-out;
}
@keyframes reveal-in {
  from { opacity: 0; transform: translateY(-0.5rem); }
}

/* ---------- block-contact ---------- */
/* The email shrinks with narrow windows so it stays on one line.
   5.5vw fits a ~26-character address; adjust for a longer one.
   A <wbr> after the @ gives it a clean place to break if needed. */
.block-contact .email {
  font-family: var(--font-mono);
  font-size: min(var(--size-h3), 5.5vw);
  overflow-wrap: anywhere;
}

/* ---------- block-footer ---------- */
.block-footer {
  padding-block: var(--space-5);
  border-top: 1px solid var(--color-line);
  font-size: var(--size-small);
  color: var(--color-muted);
}
