/* cmatts.com — one stylesheet, mobile first.
   Look measured from the old Reframe Plus theme: near-black page, light grey text,
   Lekton font, pure red (#f00) for menu hover and the current item.
   The numbers marked "set in Settings" are overwritten by a <style> block that build.py writes
   into every page from data/site.json (Settings > Layout / Page animation).
   Phone layout is the default; the @media block near the bottom changes it for wider screens. */

:root {
  --bg: #0d0d0d;
  --text: #ccc;
  --white: #fff;
  --accent: #f00;
  --line: #808080;
  --field: #1a1a1a;
  --panel: #111;
  --content-w: 1298px;      /* set in Settings: width of the text/video column */
  --footer-gap: 220px;      /* set in Settings: empty space above the footer line */
  --anim-dur: 600ms;        /* set in Settings: how long each fade/slide takes */
  --anim-dist: 70px;        /* set in Settings: how far items travel */
  --anim-stagger: 150ms;    /* set in Settings: delay between neighbouring items */
  --anim-ease: cubic-bezier(0.22, 1, 0.36, 1);  /* set in Settings: how the slide lands (a soft ease-out) */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.menu-open { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Lekton, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.7;
}
img, iframe { max-width: 100%; }
a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
a:hover, a:focus-visible { color: var(--white); }
.wrap { max-width: calc(var(--content-w) + 40px); margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- header and menu (phone first) ---------- */
.site-header {
  position: relative; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding-top: 20px; padding-bottom: 16px;
}
.logo { display: block; line-height: 0; }
.logo img { width: 96px; height: 96px; display: block; }

/* the menu button turns into an X while the menu is open */
.nav-toggle {
  display: block; width: 48px; height: 48px; padding: 0;
  background: none; border: 1px solid #444; color: var(--white); cursor: pointer;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  display: block; width: 22px; height: 2px; background: currentColor; position: relative; margin: 0 auto;
}
.nav-toggle span { transition: background .15s; }
.nav-toggle span::before, .nav-toggle span::after { content: ""; position: absolute; left: 0; }
.nav-toggle span::before { top: -7px; transition: top .2s .15s, transform .2s; }
.nav-toggle span::after { top: 7px; transition: top .2s .15s, transform .2s; }
.nav-open .nav-toggle span { background: transparent; }
.nav-open .nav-toggle span::before { top: 0; transform: rotate(45deg); transition: top .2s, transform .2s .15s; }
.nav-open .nav-toggle span::after { top: 0; transform: rotate(-45deg); transition: top .2s, transform .2s .15s; }
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* phone menu: a full panel under the header (the logo and button stay visible), items centred */
.main-nav {
  position: fixed; left: 0; right: 0; top: var(--header-h, 130px); bottom: 0; z-index: 25;
  display: flex; flex-direction: column; overflow: auto; padding: 24px 20px 48px;
  background: var(--bg);
  opacity: 0; visibility: hidden;
  transition: opacity .35s ease-out, visibility 0s linear .35s;
}
.nav-open .main-nav { opacity: 1; visibility: visible; transition: opacity .35s ease-out, visibility 0s; }
.main-nav ul { list-style: none; margin: 0; padding: 0; text-align: center; }
.main-nav > ul { margin: auto; }   /* centres the list both ways; a long list scrolls from the top */
.main-nav a { display: inline-block; color: var(--white); text-decoration: none; font-size: 22px; padding: 12px 0; }
.main-nav a:hover, .main-nav a:focus-visible,
.main-nav .current > a, .main-nav .current-parent > a { color: var(--accent); }
/* on a phone every dropdown is simply open, so the whole menu is visible at once */
.main-nav .sub-menu { padding: 0 0 8px; }
.main-nav .sub-menu a { color: #f5f5f5; font-size: 16px; padding: 5px 0; }

/* ---------- blocks: videos, images, text, grids ---------- */
.blocks > * { margin: 0 0 24px; }
.post-title { font-size: 21px; font-weight: 400; line-height: 1.5; margin: 0 0 20px; color: var(--text); }

.video { position: relative; width: 100%; aspect-ratio: var(--r, 16/9); background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.img { margin-left: 0; margin-right: 0; }
.img img { display: block; height: auto; }

.text p { margin: 0 0 1em; }
.text h3 { color: var(--white); font-size: 1.4em; font-weight: 700; margin: 1.8em 0 .5em; line-height: 1.3; }
.text > :last-child { margin-bottom: 0; }

.media-text { display: flex; flex-direction: column; gap: 14px; }
.media-text .mt-media { width: 100%; }
.media-text .mt-text > :last-child { margin-bottom: 0; }

/* a grid of pictures/videos; --cols (computer) and --pcols (phone) come from the block */
.grid-block { display: grid; grid-template-columns: repeat(var(--pcols, 2), minmax(0, 1fr)); gap: 12px; }
.grid-block .cell { min-width: 0; }
.grid-block .img { margin: 0; }
.grid-block .img img { width: 100%; height: auto; }
.grid-block.has-ar .img img { aspect-ratio: var(--ar); object-fit: cover; }

/* ---------- tag pages ---------- */
.tag-title { font-size: 21px; font-weight: 400; margin: 0 0 20px; color: var(--text); }
.grid { display: grid; grid-template-columns: 1fr; gap: 28px 20px; }
.tile { margin: 0; }
.tile .thumb { display: block; aspect-ratio: 16/9; background: #1a1a1a; overflow: hidden; position: relative; }
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .2s; }
.tile .thumb:hover img, .tile .thumb:focus-visible img { opacity: .8; }
.tile .thumb.play::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin: -14px 0 0 -9px;
  border-left: 24px solid rgba(255,255,255,.85); border-top: 14px solid transparent; border-bottom: 14px solid transparent;
  pointer-events: none;
}
.tile h2 { font-size: 15px; font-weight: 400; line-height: 1.4; margin: 8px 0 0; }
.tile h2 a { color: var(--white); text-decoration: none; }
.tile h2 a:hover, .tile h2 a:focus-visible { color: var(--accent); }

/* ---------- contact form ---------- */
.contact-form { max-width: 620px; margin-top: 32px; }
.contact-form h2 { color: var(--white); font-size: 1.4em; margin: 0 0 12px; }
.contact-form label { display: block; margin-bottom: 4px; }
.contact-form input, .contact-form textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iPhones zooming in on focus */
  color: var(--white); background: var(--field); border: 1px solid #444; border-radius: 0; padding: 12px;
}
.contact-form input:focus, .contact-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.contact-form button {
  font: inherit; font-size: 16px; color: var(--white); background: none; border: 1px solid var(--white);
  padding: 12px 28px; min-height: 48px; cursor: pointer;
}
.contact-form button:hover, .contact-form button:focus-visible { color: var(--accent); border-color: var(--accent); }
.contact-form button[disabled] { opacity: .5; cursor: default; }
.contact-form .hp { position: absolute; left: -9999px; }
.form-msg { padding: 10px 12px; border: 1px solid #444; color: var(--white); }
.form-msg.error { border-color: var(--accent); }

/* ---------- footer ---------- */
.site-footer { padding-bottom: 30px; text-align: center; }
.site-footer hr { border: 0; border-top: 1px solid var(--line); margin: calc(var(--footer-gap) / 2) 0 24px; }
.footertext { font-size: 13px; margin: 0 0 5px; }
.footertext a { text-decoration: none; }
.footertext a:hover { color: var(--accent); }

/* ---------- fade / slide in as items appear (style, speed and distance: Settings > Page animation) ----------
   Items start hidden only when JavaScript is running AND animation is on (data-anim on <html>).
   site.js adds class "in" as each item scrolls into view. */
html[data-anim="slide-up"]    { --anim-from: translateY(var(--anim-dist)); }
html[data-anim="slide-down"]  { --anim-from: translateY(calc(var(--anim-dist) * -1)); }
html[data-anim="slide-left"]  { --anim-from: translateX(calc(var(--anim-dist) * -1)); }
html[data-anim="slide-right"] { --anim-from: translateX(var(--anim-dist)); }
html[data-anim="fade"]        { --anim-from: none; }
html[data-anim="grow"]        { --anim-from: scale(.94); }

html.js[data-anim] :is(.blocks > :not(.grid-block), .grid-block > .cell, .tile, .post-title, .tag-title) {
  opacity: 0; transform: var(--anim-from);
  transition: opacity var(--anim-dur) ease-out, transform var(--anim-dur) var(--anim-ease);
  transition-delay: var(--delay, 0ms);
}
html.js[data-anim] :is(.blocks > :not(.grid-block), .grid-block > .cell, .tile, .post-title, .tag-title).in { opacity: 1; transform: none; }
/* the player fades in once Vimeo has loaded it, over the dark box */
/* (only when "Fade videos in" is on in Settings: build.py then adds data-vfade to <html>) */
html.js[data-anim][data-vfade] .video iframe { opacity: 0; transition: opacity var(--anim-dur) ease-out; }
html.js[data-anim][data-vfade] .video.ready iframe { opacity: 1; }
/* safety net if site.js did not run, and for people who prefer less motion */
html.reveal-all :is(.blocks > :not(.grid-block), .grid-block > .cell, .tile, .post-title, .tag-title),
html.reveal-all .video iframe { opacity: 1 !important; transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  html.js[data-anim] :is(.blocks > :not(.grid-block), .grid-block > .cell, .tile, .post-title, .tag-title),
  html.js[data-anim][data-vfade] .video iframe { opacity: 1; transform: none; transition: none; }
}

/* phone menu: tighter lines so the whole open menu fits on a phone screen */
@media (max-width: 760px) {
  .main-nav li { line-height: 1.2; }
  .main-nav a { line-height: 1.3; padding: 10px 0; }
  .main-nav .sub-menu a { padding: 4px 0; }
}

/* phone menu items fade/slide in one after another when the menu opens */
@media (max-width: 760px) {
  html.js[data-anim] .main-nav > ul > li {
    opacity: 0; transform: var(--anim-from);
    transition: opacity var(--anim-dur) ease-out, transform var(--anim-dur) var(--anim-ease);
  }
  html.js[data-anim] .nav-open .main-nav > ul > li {
    opacity: 1; transform: none;
    transition-delay: calc(var(--i, 0) * var(--anim-stagger) + 120ms);
  }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  html.js[data-anim] .main-nav > ul > li { opacity: 1; transform: none; transition: none; }
}

/* ---------- tablet and up (761px+) ---------- */
@media (min-width: 761px) {
  body { font-size: 13px; line-height: 1.7; }
  html.menu-open { overflow: visible; }
  .site-header { flex-wrap: nowrap; padding-top: 51px; padding-bottom: 44px; }
  .logo img { width: 150px; height: 150px; }
  .nav-toggle { display: none; }

  .main-nav, .nav-open .main-nav {
    position: static; display: block; width: auto; padding: 0; overflow: visible; background: none;
    opacity: 1; visibility: visible; transition: none;
  }
  .main-nav > ul { display: flex; gap: 28px; margin: 0; text-align: left; }
  .main-nav > ul > li { position: relative; }
  .main-nav a { display: block; font-size: 15px; padding: 8px 0; }
  .main-nav .sub-menu {
    display: none; position: absolute; right: 0; top: 100%; z-index: 10; min-width: 260px; text-align: left;
    background: var(--panel); border: 1px solid #2a2a2a; padding: 12px 20px;
  }
  .main-nav .has-sub:hover > .sub-menu, .main-nav .has-sub:focus-within > .sub-menu { display: block; }
  .main-nav .sub-menu a { font-size: 14px; padding: 5px 0; white-space: nowrap; }

  .media-text { flex-direction: row; gap: 28px; align-items: flex-start; }
  .media-text .mt-media { flex: 0 0 55%; width: auto; }
  .media-text .mt-text { flex: 1; min-width: 0; }

  .grid-block { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 23px; }

  .grid { grid-template-columns: repeat(2, 1fr); }
  .tile h2 { font-size: 14px; }
  .site-footer hr { margin-top: var(--footer-gap); }
  .footertext { font-size: 11px; }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
