/* ABOUTME: Styles for the 2048 Enllà landing page: comic panels in ink, paper, yellow, hot pink and cyan, moved by scroll. */
/* ABOUTME: Each moving element reads one registered property (--in, --out, --page); its default is the still page. */

@font-face {
  font-family: "Anton";
  src: url("fonts/anton.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

/* The scroll properties. Their initial values are the finished state, so without animation the page simply stands. */
@property --in { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --out { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --page { syntax: "<number>"; inherits: false; initial-value: 1; }

:root {
  --ink: #16131D;
  --paper: #FFF7E3;
  --yellow: #FFD33D;
  --pink: #FF2E88;
  --cyan: #1CB5F0;
  --blue: #2747D9;
  --dim: #2B2635;
  --line: 4px;
  --shadow: 8px 8px 0 var(--ink);
  --display: "Anton", "Impact", "Arial Narrow Bold", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --dots: radial-gradient(circle, rgb(22 19 29 / 0.16) 1.6px, transparent 1.8px);
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.125rem/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }

a:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.02;
  margin: 0;
  text-transform: uppercase;
  text-wrap: balance;
}

/* Masthead, with the page's progress as a loading bar along its foot */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.9rem var(--gutter);
  border-bottom: var(--line) solid var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.wordmark { display: block; flex: none; }

.wordmark img { display: block; width: auto; height: clamp(2.8rem, 5vw, 3.6rem); }

.masthead nav { display: flex; gap: clamp(1rem, 2.5vw, 2rem); }

.masthead nav a {
  font-family: var(--display);
  font-size: 1.3rem;
  text-transform: uppercase;
  text-decoration: none;
}

.masthead nav a:hover { color: var(--yellow); text-decoration: underline; text-decoration-thickness: 3px; }

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(-1 * var(--line) - 6px);
  height: 6px;
  background: var(--pink);
  transform-origin: left;
  transform: scaleX(var(--page, 1));
}

/* Hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
  max-width: calc(1280px + 2 * var(--gutter));
  min-height: calc(100svh - 80px);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) var(--gutter);
}

.hero-text { transform: translateY(calc(var(--out, 0) * -12vh)); }

.kicker {
  display: inline-block;
  margin: 0 0 1.25rem;
  padding: 0.3rem 0.8rem;
  background: var(--ink);
  color: var(--paper);
  font: 700 1rem/1.4 var(--mono);
  transform: rotate(-2deg);
}

/* The slogan is typed at a prompt, cursor still blinking. */
.kicker::before { content: "> "; color: var(--cyan); }

.kicker::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  margin-left: 0.2em;
  vertical-align: -0.15em;
  background: var(--yellow);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .kicker::after { animation: none; }
}

.hero h1 { font-size: clamp(3rem, 6.4vw, 5.6rem); }

.lede { margin: 1.5rem 0 2.25rem; max-width: 34rem; font-size: 1.2rem; }

.actions { display: flex; flex-wrap: wrap; gap: 1rem; }

.button {
  display: inline-block;
  padding: 0.85rem 1.4rem 0.75rem;
  border: var(--line) solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--ink);
  font-family: var(--display);
  font-size: 1.4rem;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}

.button-primary { background: var(--pink); }

.button:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }

.button:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }

/* Scrolling past, the panel tips over and drops back, like a page turning. */
.hero-panel {
  margin: 0;
  border: 6px solid var(--ink);
  box-shadow: 14px 14px 0 var(--ink);
  background: var(--ink);
  transform:
    translateY(calc(var(--out, 0) * 10vh))
    rotate(calc(1.2deg - var(--out, 0) * 9deg))
    scale(calc(1 - var(--out, 0) * 0.22));
}

/* The binary ticker: 2048 written three ways, sliding as the page scrolls */

.ticker {
  overflow: hidden;
  border-block: var(--line) solid var(--ink);
  background: var(--ink);
  color: var(--yellow);
}

.ticker p {
  margin: 0;
  padding: 0.9rem 0;
  white-space: nowrap;
  font: 800 clamp(1.1rem, 2.4vw, 1.7rem)/1 var(--mono);
  transform: translateX(calc(var(--page, 1) * -45%));
}

/* Who we are */

.hosts {
  max-width: calc(1280px + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(3.5rem, 8vw, 6rem) var(--gutter);
}

.hosts h2, .listen h2 { font-size: clamp(2.6rem, 6vw, 4.6rem); margin-bottom: 1.5rem; }

/* Section titles arrive split into cyan and pink, like a bad signal, and lock into place. */
.glitch {
  --off: calc(1 - var(--in, 1));
  text-shadow:
    calc(var(--off) * -18px) 0 0 var(--cyan),
    calc(var(--off) * 18px) 0 0 var(--pink),
    3px 3px 0 var(--paper);
  letter-spacing: calc(var(--off) * 0.3em);
  transform: skewX(calc(var(--off) * -14deg));
}

.listen .glitch { text-shadow: calc(var(--off) * -18px) 0 0 var(--paper), calc(var(--off) * 18px) 0 0 var(--pink); }

.hosts-head {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
}

/* Comic panels: the hosts' and the listeners', tipping into place as they arrive. */
.panel {
  margin: 0;
  border: 6px solid var(--ink);
  background: var(--ink);
  opacity: calc(0.1 + var(--in, 1) * 0.9);
}

.panel img { display: block; width: 100%; height: auto; }

.panel-listen img { aspect-ratio: 5 / 2; object-fit: cover; }

.panel-hosts {
  box-shadow: 12px 12px 0 var(--pink);
  transform: rotate(calc(-1.5deg + (1 - var(--in, 1)) * 9deg)) scale(calc(0.85 + var(--in, 1) * 0.15));
}

.panel-listen {
  margin-bottom: clamp(2rem, 5vw, 3rem);
  box-shadow: 12px 12px 0 var(--ink);
  transform: rotate(calc(0.6deg - (1 - var(--in, 1)) * 5deg)) translateY(calc((1 - var(--in, 1)) * 60px));
}

.hosts-intro {
  max-width: 40rem;
  margin: 0;
  font-size: 1.2rem;
  opacity: calc(0.15 + var(--in, 1) * 0.85);
  transform: translateY(calc((1 - var(--in, 1)) * 40px));
}

.terminals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(24rem, 100%), 1fr));
  gap: clamp(1.5rem, 4vw, 3rem);
}

.terminal {
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 10px 10px 0 var(--pink);
  padding: 0 1.5rem 1.6rem;
  font-family: var(--mono);
  opacity: calc(0.1 + var(--in, 1) * 0.9);
}

.terminal-left { transform: translateX(calc((1 - var(--in, 1)) * -16vw)) rotate(calc((1 - var(--in, 1)) * -7deg)); }

.terminal-right { transform: translateX(calc((1 - var(--in, 1)) * 16vw)) rotate(calc((1 - var(--in, 1)) * 7deg)); box-shadow: 10px 10px 0 var(--cyan); }

.terminal-bar { display: flex; gap: 0.5rem; margin: 0 -1.5rem 1.25rem; padding: 0.8rem 1.25rem; border-bottom: 2px solid var(--dim); }

.terminal-bar span { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--pink); }
.terminal-bar span:nth-child(2) { background: var(--yellow); }
.terminal-bar span:nth-child(3) { background: var(--cyan); }

.prompt { margin: 0.9rem 0 0.3rem; color: var(--cyan); font-weight: 700; }

.prompt::before { content: "$ "; color: var(--yellow); }

/* The command types itself out as the window arrives, one character at a time. */
.type {
  display: inline-block;
  vertical-align: bottom;
  overflow: hidden;
  white-space: nowrap;
  width: calc(round(down, var(--in, 1) * var(--chars), 1) * 1ch);
}

.terminal h3 { font-size: clamp(1.5rem, 2.6vw, 2rem); color: var(--yellow); }

.out { margin: 0; color: var(--paper); }

.links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; margin: 0; padding: 0; list-style: none; }

.links a { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--paper); text-decoration: none; }

.links a:hover { color: var(--yellow); text-decoration: underline; }

.links svg { width: 1.1em; height: 1.1em; flex: none; }

/* Where to listen */

.listen {
  padding: clamp(3.5rem, 8vw, 6rem) var(--gutter);
  border-top: var(--line) solid var(--ink);
  background: var(--dots) 0 0 / 14px 14px, var(--cyan);
}

.listen > * { max-width: 1280px; margin-inline: auto; }

.platforms {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

/* The cards drop in from below, tumbling a little, each with its own tilt. */
.platforms li {
  --tilt: 8deg;
  opacity: var(--in, 1);
  transform:
    translateY(calc((1 - var(--in, 1)) * 90px))
    rotate(calc((1 - var(--in, 1)) * var(--tilt)))
    scale(calc(0.8 + var(--in, 1) * 0.2));
}

.platforms li:nth-child(even) { --tilt: -10deg; }
.platforms li:nth-child(3n) { --tilt: 5deg; }

.platforms a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  height: 100%;
  padding: 1.15rem 1.35rem;
  border: var(--line) solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out, background-color 120ms ease-out;
}

.platforms a:hover { background: var(--yellow); transform: translate(-3px, -3px); box-shadow: 11px 11px 0 var(--ink); }

.platforms strong { font-family: var(--display); font-weight: 400; font-size: 1.75rem; text-transform: uppercase; }

.platforms span { font-size: 0.95rem; }

.rss { margin-top: 2.5rem; font-weight: 600; opacity: calc(0.15 + var(--in, 1) * 0.85); }

.rss-label { display: block; margin-bottom: 0.6rem; }

/* The feed address copies itself: click, and the tag flips to "copiat!" with a pop. */
.copy {
  display: inline-flex;
  align-items: stretch;
  vertical-align: middle;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  text-decoration: none;
  cursor: copy;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}

.copy:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }

.copy code {
  padding: 0.3rem 0.6rem;
  background: var(--ink);
  color: var(--yellow);
  font: 700 1rem var(--mono);
}

.copy-state {
  display: grid;
  place-items: center;
  min-width: 6.5ch;
  padding: 0.3rem 0.6rem;
  background: var(--paper);
  font: 700 0.85rem var(--mono);
  text-transform: uppercase;
}

.copy.copied .copy-state { background: var(--pink); }

.copy.copied { animation: pop 380ms cubic-bezier(0.3, 1.6, 0.5, 1); }

@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.12) rotate(-2deg); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .copy.copied { animation: none; }
}

/* Footer */

.footer {
  padding: 2.5rem var(--gutter) 5.5rem;
  background: var(--ink);
  color: var(--paper);
}

.footer p { margin: 0.4rem 0 0; max-width: 60rem; }

.eof { font: 800 clamp(2.5rem, 7vw, 4.5rem)/1 var(--mono); color: var(--pink); margin: 0 0 1rem; }

.footer a { color: var(--yellow); font-weight: 700; }

.social { display: flex; flex-wrap: wrap; gap: 0.6rem 1.6rem; margin: 1.2rem 0; padding: 0; list-style: none; }

.social a { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; }

.social a { padding: 0.3rem; }

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

.social svg { width: 1.7rem; height: 1.7rem; flex: none; }

.credits { font-size: 0.85rem; opacity: 0.8; }

/* Scroll-driven animation, where the browser has it and the visitor allows motion. Each one animates a property. */

@keyframes in { from { --in: 0; } to { --in: 1; } }
@keyframes out { from { --out: 0; } to { --out: 1; } }
@keyframes page { from { --page: 0; } to { --page: 1; } }

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .progress, .ticker p { animation: page linear both; animation-timeline: scroll(root); }
    .hero { animation: out linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
    [data-scroll]:not(.hero) { animation: in linear both; animation-timeline: view(); animation-range: entry 0% cover 35%; }
    .terminal[data-scroll] { animation-range: entry 10% cover 45%; }
    .platforms li:nth-child(3n + 2) { animation-range: entry 8% cover 40%; }
    .platforms li:nth-child(3n) { animation-range: entry 16% cover 45%; }
  }
}

/* Small screens: one column, less travel, no tilting windows. */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-panel { margin: 0 0.75rem 1rem 0; }
  .hosts-head { grid-template-columns: 1fr; }
  .panel { margin-right: 0.75rem; }
  .masthead nav a { font-size: 1.1rem; }
}

@media (max-width: 700px) {
  .terminal-left, .terminal-right { transform: translateY(calc((1 - var(--in, 1)) * 40px)); }
  .platforms { grid-template-columns: 1fr; }
  .platforms li { transform: translateY(calc((1 - var(--in, 1)) * 50px)); }
  .hero-panel { transform: rotate(1.2deg); }
}

@media (max-width: 480px) {
  .masthead nav { display: none; }
}
