/* ============================================================================
   JOMO Media — local, no-JavaScript rebuild
   ----------------------------------------------------------------------------
   Reading order of this file:
     1. @font-face      — self-hosted web fonts
     2. Design tokens   — every colour / size / spacing decision lives here
     3. Reset + base    — a handful of sane defaults
     4. Layout helpers  — .wrap, .section, .visually-hidden
     5. Components      — header, hero, card grid, about, footer
     6. Media queries   — the whole responsive story, in one place at the end

   The site needs no JavaScript. The two interactive-feeling bits are pure CSS:
     * the thumbnail captions fade in on :hover and :focus-visible
     * the layout reflows with CSS Grid + one breakpoint
   ========================================================================== */


/* ---------------------------------------------------------------- 1. FONTS */
/* Self-hosted so the page works fully offline. `font-display: swap` shows
   fallback text immediately instead of leaving a blank gap. */

@font-face {
  font-family: "Bauhaus Pro";
  src: url("../assets/fonts/bauhaus-pro-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bauhaus Pro";
  src: url("../assets/fonts/bauhaus-pro-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "ARP Display";
  src: url("../assets/fonts/arp-display-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "ARP Display";
  src: url("../assets/fonts/arp-display-900.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Azeret Mono";
  src: url("../assets/fonts/azeret-mono-latin.woff2") format("woff2");
  /* One file covers the whole 100–900 range because it is a variable font. */
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}


/* --------------------------------------------------------------- 2. TOKENS */
/* Custom properties declared on :root are global. Change a value here and it
   updates everywhere it is referenced — this is the whole point of tokens. */

:root {
  /* Palette. The site is essentially cream + charcoal with one blue accent. */
  --cream:      #fcfbf4;
  --white:      #ffffff;
  --ink:        #333333;   /* body copy                                      */
  --ink-soft:   #666666;   /* secondary copy, the name highlight bar         */
  --accent:     #0057e1;   /* link hover                                     */
  --scrim:      rgb(51 51 51 / 0.6);   /* caption overlay on thumbnails      */

  /* Type stacks. The fallback after the comma matters: it is what renders
     during the swap, and what renders if a font file ever fails to load. */
  --font-body:  "Bauhaus Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-brand: "ARP Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono:  "Azeret Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Fluid type. clamp(MIN, PREFERRED, MAX) lets a heading scale with the
     viewport but never get smaller than MIN or larger than MAX — no media
     query needed. The `vw` middle value is what does the scaling. */
  --step-hero:  clamp(4rem, 15vw, 9.375rem);    /* "JOMO"      max 150px     */
  --step-xl:    clamp(2.25rem, 6vw, 3.5rem);    /* "Media", "About" max 56px */
  --step-lg:    clamp(2rem, 5vw, 3.75rem);      /* "Portfolio" max 60px      */
  --step-md:    clamp(1.5rem, 4vw, 3rem);       /* category headings max 48px*/
  --step-sm:    clamp(1.125rem, 2.5vw, 1.5625rem); /* hero name    max 25px  */

  /* Layout. --wrap is the 980px content column the original design uses;
     --gutter is the breathing room outside it. */
  --wrap:       980px;
  --gutter:     clamp(1rem, 5vw, 5rem);
  --gap:        10px;      /* the gap between thumbnails                     */
  --hero-h:     clamp(18rem, 45vw, 32.5rem);    /* 520px tall at full size   */
}


/* ---------------------------------------------------------- 3. RESET + BASE */

/* border-box means padding and border are counted *inside* an element's
   declared width, which is how most people intuitively expect boxes to work. */
*,
*::before,
*::after { box-sizing: border-box; }

/* Kill the default margins we would otherwise have to override everywhere. */
body, h1, h2, h3, h4, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }

html {
  /* Makes in-page anchor jumps glide instead of teleport, but respects a
     "reduce motion" system preference (see the media query at the bottom). */
  scroll-behavior: smooth;
}

body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.125rem;          /* 18px — the About copy size               */
  line-height: 1.4;
  /* Smooths font rendering on macOS; harmless elsewhere. */
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;               /* removes the stray baseline gap under images */
  max-width: 100%;
  height: auto;
}

a { color: inherit; }

/* One consistent, always-visible focus ring for keyboard users. :focus-visible
   fires for keyboard/AT focus but not for mouse clicks. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}


/* ------------------------------------------------------ 4. LAYOUT HELPERS */

/* Centres a block and caps its width. `margin-inline: auto` is the logical
   (writing-direction aware) version of `margin-left/right: auto`. */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Vertical rhythm between the big page bands. */
.section {
  scroll-margin-top: 1.5rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
  max-width: calc(var(--wrap) + 2 * var(--gutter));
  margin-block: clamp(2.5rem, 6vw, 5.25rem);
}

/* Text that screen readers should announce but nobody should see. Note it is
   1px and clipped rather than `display: none`, which would hide it from
   assistive technology too. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A skip link: hidden off-screen until it receives focus, then it flies in.
   First tab stop on the page, so keyboard users can jump the nav. */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--cream);
  text-decoration: none;
  transform: translateY(-120%);
  transition: transform 150ms ease;
}
.skip-link:focus { transform: translateY(0); }


/* ----------------------------------------------------------- 5. COMPONENTS */

/* --- Site header --------------------------------------------------------- */

.site-header {
  background: var(--cream);
  padding-block: 1rem;
}

/* Two children, pushed apart. `flex-wrap` lets the nav drop below the logo on
   very narrow screens instead of squashing it. */
.site-header__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.logo {
  font-size: 1.375rem;          /* 22px */
  line-height: 1.4;
}
.logo a { text-decoration: none; }
.logo a:hover,
.logo a:focus-visible { color: var(--accent); }

.nav ul {
  display: flex;
  gap: 1.75rem;
}
.nav a {
  font-size: 1rem;
  text-decoration: none;
  padding-block: 0.25rem;
  /* Transition the colour so the hover is a fade, not a flash. */
  transition: color 400ms ease;
}
.nav a:hover,
.nav a:focus-visible,
.nav a[aria-current="page"] { color: var(--accent); }


/* --- Hero ---------------------------------------------------------------- */
/* A photo with three lines of type centred on top of it. The photo and the
   text are siblings; the text is layered over the photo with Grid, which
   avoids the usual `position: absolute` juggling. */

.hero {
  display: grid;
  margin-inline: auto;
  padding-inline: var(--gutter);
  max-width: calc(var(--wrap) + 2 * var(--gutter));
}

/* Both children are placed in the *same* grid cell, so they stack. */
.hero__img,
.hero__text { grid-area: 1 / 1; }

.hero__img {
  width: 100%;
  height: var(--hero-h);
  /* object-fit: cover crops the photo to fill the box without distorting it,
     the same way background-size: cover would — but on a real <img>, so it
     stays in the document and can have alt text. */
  object-fit: cover;
  object-position: center;
}

.hero__text {
  display: grid;
  align-content: center;        /* centre the stack vertically in the cell   */
  justify-items: center;
  text-align: center;
  cursor: default;
  padding: 1rem;
}

/* The wordmark. The four-corner text-shadow is a cheap 1px "outline" that
   keeps cream type legible over a busy photo — it is exactly what the
   original site does. */
.hero__word {
  color: var(--cream);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.05;
  font-size: var(--step-hero);
  text-shadow:
    -1px -1px 0 rgb(0 0 0 / 0.5),
    -1px  1px 0 rgb(0 0 0 / 0.5),
     1px  1px 0 rgb(0 0 0 / 0.5),
     1px -1px 0 rgb(0 0 0 / 0.5);
}
.hero__word--sm {
  font-size: var(--step-xl);
  line-height: 1.4;
}

/* The name sits in a grey highlight bar. Because the <span> is inline, the
   background hugs the text instead of the full column width. */
.hero__name { margin-top: 0.75rem; }
.hero__name span {
  background: var(--ink-soft);
  color: #000;
  font-family: var(--font-brand);
  font-weight: 900;
  font-size: var(--step-sm);
  letter-spacing: 0.03em;
  padding: 0.15em 0.5em;
  /* box-decoration-break keeps the padding looking right if the highlight
     wraps onto a second line on a narrow screen. */
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}


/* --- Thumbnail grid ------------------------------------------------------ */

.grid {
  display: grid;
  gap: var(--gap);
  /* auto-fill + minmax = a responsive grid with no media queries. Each column
     is at least 260px wide; the browser fits as many as will go and shares
     out the leftover space (1fr each). Below 260px + gap it drops to one
     column on its own.
     auto-FILL, not auto-FIT: auto-fill keeps the empty columns it created,
     so a section with a single video still shows it one-column wide instead
     of stretching it across the whole row. Swap the keyword to see it. */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
/* The `--2` / `--3` variants set a *larger* minimum column width, which is
   what caps the column count: inside the 980px content column only two 380px
   columns will fit, and only three 230px ones. `min(100%, …)` stops the
   minimum from ever exceeding the available width on a phone, which would
   otherwise cause horizontal overflow. */
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }

/* Each card is its own stacking context so the caption can sit on top. */
.card {
  position: relative;
  display: block;
  overflow: hidden;             /* clips the zoomed image to the card box    */
  background: var(--ink);
  text-decoration: none;
  /* aspect-ratio reserves the right box height before the image loads, so
     nothing jumps around as the page fills in. */
  aspect-ratio: 16 / 9;
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms ease;
}
.card:hover .card__img,
.card:focus-visible .card__img { transform: scale(1.04); }

/* The caption layer: a dark scrim plus the title, both transparent until the
   card is hovered or focused. Animating `opacity` is cheap for the browser;
   animating something like `height` would not be. */
.card__overlay {
  position: absolute;
  inset: 0;                     /* shorthand for top/right/bottom/left: 0    */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 300ms ease;
}
.card:hover .card__overlay,
.card:focus-visible .card__overlay { opacity: 1; }

.card__title {
  color: var(--white);
  font-size: 2.5rem;          /* 14px */
  text-align: center;
  text-wrap: balance;           /* avoids a lonely last word on its own line */
}

/* Items with no video link should not look clickable. */
.card--nolink { cursor: default; }


/* --- Expand panel (the per-video overlay) -------------------------------- */
/* On the real site, clicking a thumbnail opens an in-page expanded view and
   puts ?pgid=<item> in the URL. Here each video is a real page under video/
   that re-renders its gallery behind this panel, so the look matches but the
   URL is a plain file path.

   Why a page per video rather than 31 panels hidden on one page with :target?
   Because browsers do NOT lazy-load hidden iframes — display:none,
   visibility:hidden and loading="lazy" all still fetch immediately. Twenty-five
   panels on the Portfolio page would mean twenty-five YouTube players loading
   the moment the page opened. One page, one iframe. Navigating away also tears
   the player down, which is what stops the audio when you close the panel —
   a fragment change never could.

   The panel has no hidden state, so there is no :target rule here at all: if
   the markup is on the page, it is open. The backdrop, the x and the arrows
   are ordinary links, so Back/Forward work for free. The one honest gap is
   that Esc does not close it; that needs <dialog> and a line of script. */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 3vw, 2.5rem);
}

/* A full-bleed link sitting behind the panel: clicking anywhere outside the
   panel follows it and returns to the gallery. */
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  /* The original's expand view is bright, not a dark theatre. */
  background: rgb(252 251 244 / 0.97);
}

.lightbox__panel {
  position: relative;          /* so the close button can anchor to it       */
  width: min(64rem, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--white);
  box-shadow: 0 1.5rem 3rem rgb(51 51 51 / 0.18);
}

/* The responsive video box. The wrapper holds the 16:9 shape and the iframe
   fills it, because an iframe has no intrinsic aspect ratio of its own to
   scale from the way an <img> does. */
.lightbox__video {
  aspect-ratio: 16 / 9;
  background: #000;            /* avoids a white flash before the player paints */
}
.lightbox__video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;                   /* the modern replacement for frameborder="0" */
}

/* Fallback for the one item that has no video link on the original site. */
.lightbox__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.lightbox__close {
  position: absolute;
  top: 0.35rem;
  right: 0.75rem;
  z-index: 1;
  font-size: 2.25rem;
  line-height: 1;
  color: var(--white);
  text-decoration: none;
  text-shadow: 0 0 6px rgb(0 0 0 / 0.6);
}

/* Title in the middle, an arrow pinned to each side. */
.lightbox__bar {
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem 1.75rem;
}
/* Source order is prev, next, meta — so place them explicitly rather than
   letting them fall into the grid in the order they are written. */
.lightbox__nav:nth-of-type(1) { grid-column: 1; justify-self: start; }
.lightbox__nav:nth-of-type(2) { grid-column: 3; justify-self: end; }
.lightbox__meta               { grid-column: 2; grid-row: 1; text-align: center; }

.lightbox__nav {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  padding: 0 0.5rem;
  transition: color 200ms ease;
}
.lightbox__nav:hover,
.lightbox__nav:focus-visible { color: var(--accent); }

.lightbox__title {
  font-size: clamp(1.25rem, 3.5vw, 2.5rem);   /* 40px, as on the real site  */
  font-weight: 400;
  line-height: 1.4;
  text-wrap: balance;
}


/* --- About -------------------------------------------------------------- */
/* Two columns: copy on white, portrait alongside. */

.about {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  align-items: stretch;
}

.about__text {
  background: var(--white);
  padding: clamp(1.5rem, 4vw, 3.75rem);
  text-align: center;
  /* Space between the paragraphs without touching their own margins:
     the gap applies between flex children only, never at the edges. */
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  justify-content: center;
}

.about__heading {
  font-size: var(--step-xl);
  font-weight: 400;
  line-height: 1.1;
}
.about__role { font-size: 1.5rem; }        /* 24px */

/* The portrait fills its column edge to edge, whatever the column's height
   turns out to be — that is what the 100%-height + object-fit pair buys you. */
.about__portrait { overflow: hidden; }
.about__portrait img {
  width: 100%;
  height: 100%;
  min-height: 20rem;
  object-fit: cover;
  object-position: center 30%;  /* nudges the crop toward the face           */
}


/* --- Portfolio page ----------------------------------------------------- */

.page-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-lg);
  letter-spacing: 0.02em;
  text-align: center;
  margin-block: clamp(2rem, 6vw, 4rem) 0;
}

.cat { margin-block: clamp(1.5rem, 4vw, 2.5rem); }

/* The original design draws its section divider with a run of underscore
   characters. It is kept here because it is part of the site's look, but it
   is marked aria-hidden in the HTML so screen readers skip the noise.
   The tidier way to do this is a styled `<hr>` or a ::before with a border —
   try swapping it out as an exercise. */
.cat__rule {
  font-size: var(--step-md);
  line-height: 1;
  text-align: center;
  color: var(--ink);
  /* Underscores can overflow their line box; hiding the overflow keeps the
     rule from widening the page on small screens. */
  overflow: hidden;
}

.cat__heading {
  font-family: var(--font-mono);
  font-weight: 200;
  font-size: var(--step-md);
  text-align: center;
  text-wrap: balance;
  margin-block: 0.25em 1em;
}


/* --- Footer ------------------------------------------------------------- */

.site-footer {
  background: var(--cream);
  min-height: 96px;
  display: flex;
  align-items: center;
  margin-top: clamp(2rem, 6vw, 4rem);
}
.site-footer__name {
  font-size: 0.875rem;
  color: var(--ink-soft);
  text-align: center;
}


/* ------------------------------------------------------ 6. MEDIA QUERIES */

/* Flatten the hero into a banner on phones.
   ---------------------------------------------------------------------------
   The problem this solves: --hero-h is clamp(18rem, 45vw, 32.5rem), and every
   clamp() has a floor. Below about 640px the 45vw middle value drops under the
   18rem minimum, so the height STOPS shrinking and sits at 288px while the
   screen keeps narrowing. At 320px that is a 288x288 square, which reads as
   another video thumbnail instead of a banner. The same floors affect the type
   sizes inside it. So this query exists to lift those floors, not to invent
   new sizing.

   Note the breakpoint is 40rem here but 47.5rem for the About section below.
   That is deliberate: a breakpoint should go where a particular piece of the
   design actually breaks, not at some blessed "tablet" number. 40rem is simply
   where --hero-h hits its floor.

   The trick worth stealing: the overrides are declared on `.hero`, not on
   `:root`. Custom properties inherit down the tree, so redefining a token on a
   component re-points every use of it inside that component and nothing else.
   --step-xl is also what sizes the "About" heading; because this block scopes
   it to .hero, that heading keeps its own size. */

@media (max-width: 40rem) {         /* 640px — where --hero-h hits its floor */
  .hero {
    --step-hero: 12vw;              /* was clamp(4rem, 15vw, 9.375rem)       */
    --step-xl:   5vw;               /* was clamp(2.25rem, 6vw, 3.5rem)       */
    --step-sm:   3.4vw;             /* was clamp(1.125rem, 2.5vw, 1.5625rem) */
  }

  /* Swap the fixed height for a ratio. aspect-ratio measures the ELEMENT,
     while vw measures the VIEWPORT — and the hero sits inside gutters, so the
     two are not the same number. A ratio stays correct whatever the gutters do.
     12/5 is the photo's own 2400x1002 proportion, so on phones it is shown
     uncropped; the desktop rule deliberately crops it squarer, matching the
     521px-tall band on the original site. */
  .hero__img {
    height: auto;
    aspect-ratio: 12 / 5;
  }

  /* Reclaim the vertical space the type was using, so the wordmark sits in a
     shallow band rather than filling it. */
  .hero__text { padding: 0.5rem; }
  .hero__name { margin-top: 0.4rem; }
}

/* Stack the About section once there is no longer room for two columns.
   Apart from the hero query above, this is the only width breakpoint in the
   site; everything else is intrinsically fluid. */
@media (max-width: 47.5rem) {      /* 760px */
  .about { grid-template-columns: 1fr; }
  .about__portrait { order: -1; }  /* portrait first when stacked           */
  .about__portrait img {
    max-height: 60vh;
    object-position: center 25%;
  }
}

/* Touch devices have no hover, so a hover-only caption would be invisible
   there. `hover: none` targets exactly those devices and shows the titles
   permanently instead. */
@media (hover: none) {
  .card__overlay {
    opacity: 1;
    background: linear-gradient(to top, rgb(51 51 51 / 0.85), rgb(51 51 51 / 0) 60%);
    align-items: flex-end;
  }
  .card__title { text-align: left; }
}

/* Respect the OS-level "reduce motion" setting: no scaling, no smooth scroll. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .card:hover .card__img,
  .card:focus-visible .card__img { transform: none; }
}

/* Printing: drop the photo-heavy hero scrim and let the type go dark. */
@media print {
  :root { --cream: #fff; }
  .skip-link, .nav { display: none; }
  .hero__word { color: var(--ink); text-shadow: none; }
  .card__overlay { position: static; opacity: 1; background: none; }
  .card__title { color: var(--ink); }
  .lightbox { display: none; }
}
