:root {
  color-scheme: dark;
  --bg: #0f0f10;
  --surface: #18181a;
  --text: #ececef;
  --muted: #a0a0a8;
  --subtle: #c9c9cf;
  --border: #2a2a2e;
  --placeholder: #2c2c31;
  --placeholder-line: #4a4a52;
  --accent: #019900;
  --accent-light: #3fd13f;
  --event-bg: #2a1c2b;
  --event-line: #5e3d61;
  --event-strong: #e3a6e7;
  --event-text: #d8cdd9;
  --radius: 0.625rem;
  --max: 53.75rem;
  /* Fluid spacing: small on phones, larger on desktop. */
  --gutter: clamp(1rem, 0.75rem + 1vw, 1.5rem);
  --card-pad: clamp(1rem, 0.8rem + 0.8vw, 1.25rem);
  --section-gap: clamp(2.5rem, 1.75rem + 3vw, 4rem);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 Arial, Helvetica, "Liberation Sans", Arimo, sans-serif;
}

a { color: var(--accent-light); }

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Header */
.site-header {
  position: relative;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  /* Same spacing as between nav links, so the icon is evenly spaced after them. */
  gap: clamp(0.75rem, 0.25rem + 2vw, 1.75rem);
  height: clamp(3.5rem, 2.6rem + 2.8vw, 5rem);
}

.logo {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 0.3rem + 0.7vw, 0.875rem);
  font-weight: 700;
  font-size: clamp(0.95rem, 0.6rem + 1.25vw, 1.6rem);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

/* Trim the text box to the capital letters so the name centers on the logo mark. */
.logo-text {
  line-height: 1;
  text-box: trim-both cap alphabetic;
}

.logo-mark {
  flex: none;
  width: clamp(1.75rem, 1.2rem + 1.8vw, 2.75rem);
  height: clamp(1.75rem, 1.2rem + 1.8vw, 2.75rem);
  border-radius: 50%;
  border: 1px solid #ffffff;
  object-fit: cover;
  background: #000000;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 0.25rem + 2vw, 1.75rem);
  margin-left: auto;
  font-size: clamp(0.9rem, 0.7rem + 0.7vw, 1.2rem);
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  /* Same underline space on every link so the active one doesn't shift up. */
  border-bottom: 2px solid transparent;
  padding-bottom: 0.125rem;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--text);
}

.nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
}

.social {
  display: flex;
  color: var(--muted);
  /* Match the nav links' underline space so the icon lines up with their text. */
  padding-bottom: calc(0.125rem + 2px);
}

.social:hover { color: var(--text); }

/* Sized to match the hamburger icon's visual weight (its bars are 1.5rem wide but only ~1rem tall). */
.social svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Hamburger button: phones only. */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.5rem;
  padding: 0 0.5rem;
  background: none;
  border: 0;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

/* Turn the three bars into an X while the menu is open. */
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(calc(0.3rem + 2px)) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(calc(-0.3rem - 2px)) rotate(-45deg); }

/* Event banner */
.event-banner {
  background: var(--event-bg);
  border-bottom: 1px solid var(--event-line);
  color: var(--event-text);
  font-size: clamp(0.75rem, 0.55rem + 0.7vw, 1.2rem);
  text-align: center;
  padding: clamp(0.375rem, 0.2rem + 0.6vw, 0.75rem) 0;
}

.event-banner strong {
  color: var(--event-strong);
  font-weight: 600;
}

/* Page intro */
.intro {
  padding: clamp(2.25rem, 1.5rem + 3vw, 3.5rem) 0 clamp(1.5rem, 1.25rem + 1vw, 2rem);
}

.intro h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 1.35rem + 1vw, 2rem);
  line-height: 1.2;
}

.intro p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

/* Downloads list */
.downloads {
  list-style: none;
  margin: 0 0 var(--section-gap);
  padding: 0;
  display: grid;
  gap: clamp(0.75rem, 0.5rem + 1vw, 1rem);
}

.download {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--card-pad);
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-pad);
}

.download .thumb {
  grid-row: span 2;
  width: clamp(3.5rem, 3rem + 2vw, 4.125rem);
  aspect-ratio: 11 / 17;
  height: auto;
  border-radius: 0.25rem;
  border: 1px solid var(--placeholder-line);
  object-fit: cover;
  /* The crossed-box background only shows until the cover image loads. */
  background:
    linear-gradient(to top right, transparent calc(50% - 0.5px), var(--placeholder-line) calc(50% - 0.5px), var(--placeholder-line) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to bottom right, transparent calc(50% - 0.5px), var(--placeholder-line) calc(50% - 0.5px), var(--placeholder-line) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    var(--placeholder);
}

.download .body {
  flex: 1;
  min-width: 0;
}

.download h2 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.05rem, 1rem + 0.25vw, 1.15rem);
}

.badge-new {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.4rem;
  /* Letter-spacing adds space after the last letter, so trim it from the right padding. */
  padding: 0.3em calc(0.5em - 0.06em) 0.3em 0.5em;
  border: 1px solid var(--event-line);
  border-radius: 0.25rem;
  background: var(--event-bg);
  color: var(--event-strong);
  font-size: clamp(0.65rem, 0.62rem + 0.1vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  /* Trim the line box to the capital letters so the text sits centered vertically. */
  text-box: trim-both cap alphabetic;
}

.download p {
  margin: 0 0 0.5rem;
  color: var(--muted);
}

/* Synopsis: collapsed to about three lines, with the last line blurred and faded. */
.synopsis {
  --collapsed: calc(1.6em * 3);
  position: relative;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.synopsis p { margin: 0 0 0.75rem; }
.synopsis p:last-child { margin-bottom: 0; }

.js .synopsis.is-collapsible {
  overflow: hidden;
  max-height: var(--collapsed);
  transition: max-height 0.3s ease;
  cursor: pointer;
  /* Fade the text out towards the bottom of the collapsed area. */
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, rgba(0, 0, 0, 0.35));
  mask-image: linear-gradient(to bottom, #000 55%, rgba(0, 0, 0, 0.35));
}

/* Blur the last visible line; the mask feathers the blur in from above. */
.js .synopsis.is-collapsible::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: calc(1.6em * 1.25);
  -webkit-backdrop-filter: blur(1.5px);
  backdrop-filter: blur(1.5px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 60%);
  mask-image: linear-gradient(to bottom, transparent, #000 60%);
  pointer-events: none;
}

.js .synopsis.is-expanded {
  cursor: auto;
  -webkit-mask-image: none;
  mask-image: none;
}

.js .synopsis.is-expanded::after { display: none; }

.synopsis-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  margin: 0 0 0.5rem;
  padding: 0;
  background: none;
  border: 0;
  color: var(--subtle);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.synopsis-toggle::after {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform 0.2s ease;
}

.synopsis-toggle[aria-expanded="true"]::after { transform: translateY(0.1em) rotate(-135deg); }
.synopsis-toggle:hover { color: var(--text); }

.download .subtitle {
  margin: -0.125rem 0 0.5rem;
  color: var(--subtle);
  font-size: clamp(0.9rem, 0.87rem + 0.15vw, 0.95rem);
  font-weight: 500;
}

.meta {
  font-size: clamp(0.8rem, 0.78rem + 0.1vw, 0.85rem);
  color: var(--muted);
}

.meta span { white-space: nowrap; }

.formats {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 0.1rem + 1.5vw, 1rem);
  margin-top: 0.75rem;
  /* Slightly smaller on narrow phones so both links and the divider fit on one line. */
  font-size: clamp(0.875rem, 0.75rem + 0.6vw, 1rem);
  white-space: nowrap;
}

.format-sep {
  color: var(--placeholder-line);
  font-weight: 400;
}

/* Download links: equal-weight text links with a small download arrow. */
.format-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: var(--accent-light);
  font-weight: 600;
  text-decoration: none;
}

.format-link::before {
  content: "";
  flex: none;
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat;
}

.file-size {
  color: var(--muted);
  font-weight: 400;
}

.format-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Text for screen readers only. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* About and Terms pages */
.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 0.75rem + 2vw, 1.75rem);
  margin-bottom: var(--section-gap);
}

.prose h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: clamp(1.1rem, 1.05rem + 0.25vw, 1.2rem);
}

.prose h2:first-child { margin-top: 0; }

.prose p { margin: 0 0 0.75rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: clamp(1.25rem, 1rem + 1vw, 1.5rem) 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.anti-copyright {
  color: var(--subtle);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Phones: hamburger menu. */
@media (max-width: 37.5rem) {
  .menu-toggle { display: flex; }
  .social { margin-left: auto; padding-bottom: 0; }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.4);
    font-size: 1rem;
  }

  .nav.is-open { display: flex; }

  /* Let the Read | Print row use the full card width, under the cover. */
  .download .thumb { grid-row: auto; }
  .formats { grid-column: 1 / -1; }

  .nav a {
    padding: 0.875rem var(--gutter);
    border-bottom: 0;
    border-top: 1px solid var(--border);
    border-left: 3px solid transparent;
  }

  .nav a[aria-current="page"] {
    border-left-color: var(--accent);
    background: var(--bg);
  }
}
