/* ============================================
   TypeMedia 2025 — shared stylesheet
   Tokens follow the Figma file "TM2425-Website": 00 Foundations
   (colours, type scale) and the phone / tablet / desktop frames.
   ============================================ */

/* Tonka, the site's own text font. A variable font: one file holding every
   weight (100 to 1000) and slant, so these descriptors are ranges. swap = show
   a fallback font until the file has arrived, rather than invisible text. */
@font-face {
  font-family: 'Tonka';
  src: url('fonts/TonkaNormalVariable.woff2') format('woff2');
  font-weight: 100 1000;
  font-style: oblique 0deg 10deg;
  font-display: swap;
}

/* IBM Plex Sans Arabic (Google Fonts, SIL Open Font License), self-hosted like
   Tonka. Only Google's Arabic subset: unicode-range tells the browser to use
   this file for Arabic characters only, so Latin words in the Arabic text
   (TypeMedia, KABK) stay in Tonka. */
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('fonts/IBMPlexSansArabic-Regular-arabic.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  /* Colour — TM2425 colours */
  --gray-100: #eeedea;
  --base-light: #f8f8f7;
  --base-dark: #090e1f;
  --primary-000: #fbfaff;
  --primary-300: #5380f8;
  --primary-500: #0e43c0;

  /* What each colour is for. Components use these, so dark mode only has to
     change them, in one place (below). */
  --bg: var(--gray-100);           /* landing page background */
  --panel: var(--base-light);      /* dropdowns and inner pages */
  --text: var(--base-dark);
  --link-hover: var(--primary-500);

  /* Type */
  --font-sans: 'Tonka', -apple-system, system-ui, sans-serif;

  /* Scale — phone values; tablet and desktop override below */
  --page-pad: 16px;     /* outer page margin */
  --space-s: 16px;      /* spacer/spacer-s */
  --space-xl: 32px;     /* spacer/spacer-xl */
  --radius: 8px;        /* spacer/spacer-xs, used as corner radius */
  --text-wordmark: 18px;
  --text-h4: 24px;
  --text-h1: 36px;
}

/* Dark mode: on when <html> has data-theme="dark" (the footer switch sets it).
   color-scheme also makes the browser's own parts, like scrollbars, dark. */
:root[data-theme="dark"] {
  --bg: #2b2b2a;
  --panel: #383836;
  --text: var(--gray-100);
  --link-hover: #8fabfb; /* a lighter --primary-300, readable on the grey */
  color-scheme: dark;
}

@media (min-width: 768px) {
  :root {
    --page-pad: 24px;
    --space-s: 24px;
    --space-xl: 44px;
    --radius: 16px;
    --text-h1: 48px;
  }
}

@media (min-width: 1200px) {
  :root {
    --page-pad: 96px;
    --space-s: 32px;
    --space-xl: 56px;
    --radius: 24px;
    --text-wordmark: 22px;
    --text-h4: 28px;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
body.is-landing { background: var(--bg); }

/* height: auto so the width/height attributes eleventy-img adds only reserve
   the aspect ratio instead of forcing a fixed pixel height */
img { max-width: 100%; height: auto; display: block; }

a { color: inherit; }
a:hover { color: var(--link-hover); }

:focus-visible {
  outline: 2px solid var(--link-hover);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* A student's colour (--c, set per project in the HTML), exactly as each
   student chose it: the same in light and dark mode. */
.project,
.splash__letter { --student-c: var(--c, var(--primary-500)); }

/* One colour per letter (Segmentor): each letter carries its own --lc, shown
   on hover and while open. */
.project__summary:hover .lc,
.project[open] .lc { color: var(--lc); fill: var(--lc); }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between; /* wordmark left, About right */
  gap: 10px;
  padding: var(--space-s) var(--page-pad);
  /* The splash letters can fly behind the header. position + z-index keep it
     on top of them; pointer-events: none lets the mouse reach a letter through
     the empty parts of the strip, and only the two links stay clickable. */
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.site-header a { pointer-events: auto; }
.wordmark,
.site-nav a {
  font-weight: 700;
  font-size: var(--text-wordmark);
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

/* ---------- Landing: physics splash (splash.js) ---------- */
/* A box about one screen tall. splash.js drops the names into it and moves
   each letter with a CSS transform every frame. */
.splash {
  position: relative;
  /* .landing has side padding (--page-pad, the space beside the project
     dropdowns). Negative margins take back half of it, so the letters get
     closer to the window edge than the dropdowns, with a little air left */
  margin-inline: calc(var(--page-pad) / -2);
  height: calc(100svh - 120px); /* leaves room for the header; svh = height of the small (mobile) viewport */
  min-height: 360px;
  margin-bottom: var(--space-xl);
}
/* Below desktop the header is shorter, so without this the first project
   dropdown peeks in at the bottom of the screen on load. These values push it
   just below the fold: it appears with the first scroll. */
@media (max-width: 767px) {
  .splash { height: calc(100svh - 72px); margin-bottom: 40px; }
}
@media (min-width: 768px) and (max-width: 1199px) {
  .splash { margin-bottom: 64px; }
}
.splash[hidden] { display: none; }
/* iPhones only: they ask permission before sharing motion (see splash.js) */
.splash__shake {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  padding: 8px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  white-space: nowrap;
}
.splash__stage {
  position: absolute;
  inset: 0;
  /* Nothing is cut off at the top, so letters show behind the see-through
     header, up to the edge of the window. Descenders may hang a little below
     the floor (overflow: hidden would cut them off). The sides open up to the
     window edge (the half --page-pad .splash takes back), because the walls
     only stop a letter's box and italic or swash ink can stick out past it. */
  clip-path: inset(-100vh calc(var(--page-pad) / -2) -60px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation; /* swiping still scrolls; double-tap doesn't zoom */
}
.splash__word {
  position: absolute;
  top: 0;
  left: 0;
  white-space: pre;
  line-height: 1;
  transform-origin: 50% 50%;
  will-change: transform;  /* hint: this element moves every frame */
}
.splash__word--svg { position: absolute; }
.splash__word--svg .splash__letter { position: absolute; }
.splash__letter {
  display: inline-block;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  -webkit-touch-callout: none; /* no iPhone link preview when a letter is held */
  transition: color 0.15s;
}
.splash__letter svg { display: block; fill: currentColor; }
.splash__letter svg * { fill: currentColor; }
/* After shattering each letter is placed on its own */
.splash__letter.is-loose {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 50%;
  will-change: transform;
}
/* Hover: all letters of the same student take that student's colour (--c) */
.splash__letter.is-hot { color: var(--student-c); }
.splash__letter { -webkit-user-drag: none; }
.splash__stage.is-dragging,
.splash__stage.is-dragging .splash__letter { cursor: grabbing; }

/* ---------- Landing: project sections ---------- */
.landing { padding: 0 var(--page-pad); }

/* Each project is a collapsible light panel (<details>). Closed, only the
   summary row shows: the typeface name (SVG wordmark) on the left and the
   student's name on two lines on the right, both --name-h tall. */
.projects { display: grid; gap: 8px; }
.project {
  --name-h: 28px;
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
  /* when it scrolls into view, stop a little below the top edge */
  scroll-margin-top: var(--space-s);
}
@media (min-width: 768px) { .project { --name-h: 36px; } }
@media (min-width: 1200px) { .project { --name-h: 44px; } }

.project__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  padding: calc(var(--space-s) * 0.6) var(--space-s); /* slimmer bar: less space above and below */
  cursor: pointer;
  list-style: none;            /* hides the default ▸ triangle… */
  transition: color 0.15s;
}
.project__summary::-webkit-details-marker { display: none; } /* …in Safari too */
/* Hover (and while open): the student's colour, same as their falling letters */
.project__summary:hover,
.project[open] .project__summary { color: var(--student-c); }

.project__wordmark {
  height: var(--name-h);
  width: auto;
  flex: 0 1 auto;              /* may shrink (keeping its proportions) if the row is tight */
  min-width: 0;
  fill: currentColor;          /* the SVG shapes take the text colour */
}
.project__name {               /* fallback when there's no wordmark */
  font-size: var(--name-h);
  line-height: 1;
  letter-spacing: -0.03em;
}
/* Two lines (first name, family name) that together are --name-h tall.
   The block sits at the right edge (the row's space-between pushes it
   there); the text inside it is aligned left. */
.project__student {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  font-size: calc(var(--name-h) / 2);
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;         /* always exactly two lines */
  flex: none;
  width: var(--student-w, auto); /* same width for every row, set by script.js */
}

/* ---------- Inner pages (project, about) ---------- */
.page { padding: 0 var(--page-pad); }

.page-title {
  margin: 0;
  padding: var(--space-xl) var(--space-s) var(--space-s);
  font-weight: 400;
  font-size: var(--text-h1);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.prose {
  padding: var(--space-s);
  font-size: 18px;
  line-height: 1.4;
}
.prose p { max-width: 822px; margin: 0 0 1.4em; }
.prose p:last-child { margin-bottom: 0; }
.prose--center p { margin-left: auto; margin-right: auto; }
.prose--intro { padding-top: var(--space-xl); }
.prose .prose__bio {
  padding-top: 1.4em;
  border-top: 1px solid var(--text);
}
/* Links under the bio: one per line, no bullets */
.prose__links {
  max-width: 822px;
  margin: 1.4em auto 0;
  padding: 0;
  list-style: none;
}
/* A second language under the first (Kabreet's Arabic). Tonka has no Arabic,
   so Arabic letters are set in IBM Plex Sans Arabic. */
.prose--translation { padding-top: 0; }
.prose--translation[lang="ar"] { font-family: 'IBM Plex Sans Arabic', 'Tonka', sans-serif; }
.prose--translation p:first-child {
  padding-top: 1.4em;
  border-top: 1px solid var(--text);
}

/* Project images: every image sits in a 3:4 frame (Instagram's format).
   Phones: one per row. Wider: a grid of two columns where every third
   frame (1st, 4th) spans both columns, so big, two small, big, two small. */
.gallery {
  display: grid;
  gap: var(--space-s);
  padding: var(--space-s);
}
@media (min-width: 768px) {
  .gallery { grid-template-columns: 1fr 1fr; }
  .gallery__frame--big { grid-column: 1 / -1; }
}
.gallery__frame {
  aspect-ratio: 3 / 4;
  background: var(--bg); /* shows around images that aren't 3:4 */
  border-radius: var(--radius);
  overflow: hidden;
}
.gallery__frame--hero { aspect-ratio: 16 / 9; }
.gallery__frame picture { display: contents; } /* eleventy-img wraps each <img> in a <picture> */
.gallery__frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;         /* whole image, no cropping */
}
/* The hero fills its frame (crops instead). This must come after the rule
   above: equally specific CSS rules are won by the one that comes last. */
.gallery__frame--hero img { object-fit: cover; }

.caption-row {
  padding: 0 var(--space-s) var(--space-s);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.01em;
}
/* Image credits and Back to top both start at the left edge, in line with
   the wordmark (not centred like the text column above) */
.caption-row p { max-width: 822px; margin: 0 0 0.5em; }
/* Back to top on the left, Collapse on the right of the same row */
.caption-row__nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 1em;
}
.caption-row__collapse {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline; /* looks like the link next to it */
  cursor: pointer;
}
.caption-row__collapse:hover { color: var(--link-hover); }
/* Back to top lands on the project list: a little space above it, so the
   first project isn't stuck to the window edge */
.projects { scroll-margin-top: var(--space-s); }

/* ---------- About ---------- */
.about-image { padding: var(--space-s); }
.about-image img {
  width: 100%;
  /* aspect-ratio keeps the box this shape at any width; object-fit: cover
     fills it, cropping what doesn't fit */
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: cover;
  border-radius: var(--radius);
}
@media (min-width: 768px) {
  .about-image img { aspect-ratio: 4 / 3; }
}
@media (min-width: 1200px) {
  .about-image img { aspect-ratio: 16 / 9; }
}

.thanks { margin: 0; }
.thanks__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-s);
  margin: var(--space-s);
  padding-top: var(--space-s);
  border-top: 1px solid var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.thanks__row dd { margin: 0; }
/* Desktop: label and names sit in the 2nd and 3rd of three columns */
@media (min-width: 1200px) {
  .thanks__row { grid-template-columns: repeat(3, 1fr); }
  .thanks__row dt { grid-column: 2; }
}

/* Desktop: line the About page up with the header. .page already has the
   header's side margin (--page-pad); the blocks inside add their own
   --space-s padding, which is dropped here so text and image start where
   "TypeMedia 2025" does and the image gets that much wider. */
@media (min-width: 1200px) {
  .page--about .prose,
  .page--about .about-image,
  .page--about .page-title { padding-left: 0; padding-right: 0; }
  .page--about .thanks__row { margin-left: 0; margin-right: 0; }
}

/* ---------- Footer ---------- */
.site-footer {
  display: grid;
  grid-template-columns: 1fr;
  padding: var(--space-xl) var(--page-pad) var(--space-s);
}
.site-footer__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 var(--space-s);
  font-size: 14px;
  line-height: 1.4;
}
.site-footer__text p { margin: 0 0 1.4em; }

/* inline-block = wraps to a new line as one piece, never leaving a lone word */
.site-footer__keep { display: inline-block; }

/* Light/dark switch: a small circle, outlined in light mode and filled in dark
   mode. On phones and tablets it sits under the text (order: 1 = after it). */
/* Two little foosball players (an inline SVG in base.njk). The ball sits at
   the left player's feet in light mode and at the right one's in dark mode;
   clicking makes the player with the ball kick it across. */
.theme-switch {
  order: 1;
  position: relative;
  flex: none;
  width: 56px;
  height: 37px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
.theme-switch:hover { color: var(--link-hover); }
.theme-switch svg { display: block; width: 100%; height: 100%; overflow: visible; }
.theme-switch svg * { fill: currentColor; }
.theme-switch svg path:first-child { fill: none; stroke: currentColor; stroke-width: 1; } /* the rod */
/* Each player swings around its rod, like a real foosball figure */
.theme-switch__player { transform-box: view-box; }
.theme-switch__player--left { transform-origin: 8px 5px; }
.theme-switch__player--right { transform-origin: 36px 5px; }
/* Sun at the top in light mode; each click turns the arm another half circle,
   always clockwise, so the sun sets and the moon comes up (and the other way).
   script.js counts the turns in --orbit. */
.theme-switch .theme-switch__sun path { fill: none; stroke: currentColor; stroke-width: 0.8; stroke-linecap: round; }
.theme-switch__orbit {
  transform-box: view-box;
  transform-origin: 22px 2px;
  transition: transform 0.6s cubic-bezier(0.45, 0, 0.3, 1);
}
.theme-switch__orbit { transform: rotate(var(--orbit, 0deg)); }
.theme-switch__ball { transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.4, 1) 0.1s; }
.theme-switch[aria-checked="true"] .theme-switch__ball { transform: translateX(16px); }
/* .is-kicking is added by script.js on click; aria-checked is already the new
   value, so dark = the left player just kicked, light = the right one */
.theme-switch.is-kicking[aria-checked="true"] .theme-switch__player--left { animation: kick 0.35s ease-out; }
.theme-switch.is-kicking[aria-checked="false"] .theme-switch__player--right { animation: kick-left 0.35s ease-out; }
@keyframes kick {
  0%   { transform: rotate(0); }
  35%  { transform: rotate(35deg); }   /* wind up: foot swings back */
  60%  { transform: rotate(-50deg); }  /* kick: foot swings forward */
  100% { transform: rotate(0); }
}
@keyframes kick-left {                 /* the same, mirrored */
  0%   { transform: rotate(0); }
  35%  { transform: rotate(-35deg); }
  60%  { transform: rotate(50deg); }
  100% { transform: rotate(0); }
}
/* An invisible larger area around it, so it's easy to hit with a finger */
.theme-switch::before {
  content: '';
  position: absolute;
  inset: -14px;
}

/* Desktop: one row. The two outer columns are equal (1fr each), which keeps
   the switch in the exact middle. */
@media (min-width: 1200px) {
  .site-footer { display: block; }
  .site-footer__text {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    padding: 0;
  }
  .site-footer__text p { margin: 0; }
  .site-footer__copyright { text-align: right; }
  .theme-switch { order: 0; }
}
