/* Wandering Ember Studios
   Afterglow palette + Editorial type. Tokens mirror spec.md; colors outside
   the six core values are transparency treatments of those values only. */

:root {
  --color-nightfall: #1D1A2B;
  --color-plum: #30283D;
  --color-coral: #F18B80;
  --color-moonlight: #F4E6CF;
  --color-lilac: #B7A9D4;
  --color-haze: #C4BACC;

  --background: var(--color-nightfall);
  --surface: var(--color-plum);
  --text-primary: var(--color-moonlight);
  --text-secondary: var(--color-haze);
  --action-primary: var(--color-coral);
  --action-primary-text: var(--color-nightfall);
  --accent-secondary: var(--color-lilac);
  --link: var(--color-lilac);
  --focus-ring: var(--color-lilac);

  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: Arial, Helvetica, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --radius-brand-card: 18px;
  --radius-panel: 6px;
  --radius-control: 4px;

  /* Site-level additions */
  --eyebrow: var(--color-lilac);
  --rule: rgb(196 186 204 / 0.18);
  --dot: rgb(244 230 207 / 0.55);
  --wrap: 1520px;
  --gutter: clamp(20px, 5vw, 72px);
  --header-h: 88px;
}

.theme-light {
  --background: var(--color-moonlight);
  --surface: var(--color-moonlight);
  --text-primary: var(--color-nightfall);
  --text-secondary: var(--color-plum);
  --link: var(--color-plum);
  --focus-ring: var(--color-plum);

  --eyebrow: var(--color-plum);
  --rule: rgb(48 40 61 / 0.2);
  --dot: rgb(48 40 61 / 0.5);
}

/* ---------- Base ---------- */

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  font: 400 1rem/1.6 var(--font-body);
  overflow-x: clip;
}

/* A whisper of film grain over everything, so the flat fills feel like paper. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

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

h1,
h2,
h3,
h4,
p,
dl,
dd {
  margin: 0;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
}

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

::selection {
  background: var(--color-coral);
  color: var(--color-nightfall);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 60;
  padding: 12px 16px;
  border-radius: var(--radius-control);
  background: var(--color-moonlight);
  color: var(--color-nightfall);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
}

/* ---------- Type ---------- */

.display {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--text-primary);
  text-wrap: balance;
}

.display em {
  font-style: italic;
}

.eyebrow {
  margin-bottom: 20px;
  color: var(--eyebrow);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  min-height: 48px;
  padding: 0 1.4em;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: 700 1rem/1.2 var(--font-body);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  transition:
    translate 0.2s ease,
    box-shadow 0.25s ease,
    border-color 0.2s ease,
    text-decoration-color 0.2s ease;
}

.button-primary {
  background: var(--action-primary);
  color: var(--action-primary-text);
}

.button-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: rgb(183 169 212 / 0.35);
}

.button-arrow {
  transition: translate 0.2s ease;
}

@media (hover: hover) {
  /* Hover adds an underline and a lift, so state never relies on color alone. */
  .button:hover {
    translate: 0 -2px;
    text-decoration-color: currentColor;
  }

  .button-primary:hover {
    box-shadow: 0 10px 28px -10px rgb(241 139 128 / 0.75);
  }

  .button-secondary:hover {
    border-color: var(--color-lilac);
  }

  .button:hover .button-arrow {
    translate: 4px 0;
  }
}

/* ---------- Header ---------- */

.site-header {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--wrap);
  min-height: var(--header-h);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border-radius: 999px;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-name {
  font: 400 1.125rem/1 var(--font-display);
  letter-spacing: -0.01em;
}

/* The eyespot from the moth's wing: coral disc, moonlight pupil, lilac ring. */
.eyespot-mark {
  --size: 34px;
  position: relative;
  display: block;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--color-moonlight) 0 18%, var(--color-coral) 19% 58%, transparent 59%),
    radial-gradient(circle, transparent 0 68%, rgb(183 169 212 / 0.9) 69% 76%, transparent 77%);
  box-shadow: 0 0 0 0 rgb(241 139 128 / 0.4);
  transition:
    rotate 0.4s ease,
    box-shadow 0.4s ease,
    scale 0.2s ease;
}

@media (hover: hover) {
  .brand:hover .eyespot-mark {
    rotate: 20deg;
    box-shadow:
      0 0 0 5px rgb(241 139 128 / 0.18),
      0 0 24px rgb(241 139 128 / 0.45);
  }

  .brand:hover .brand-name {
    text-decoration: underline;
    text-decoration-color: var(--color-lilac);
    text-underline-offset: 0.35em;
  }
}

.nav-list {
  display: flex;
  gap: clamp(20px, 3vw, 40px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: inline-block;
  padding-block: 10px;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.4em;
  transition: text-decoration-color 0.2s ease;
}

.nav-list a:hover {
  text-decoration-color: var(--color-lilac);
}

/* ---------- Hero ---------- */

.hero {
  --hero-h: clamp(560px, calc(100svh - var(--header-h)), 920px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

/* A sparse star field, after the dotted routes on the moth's wings. Three
   layers at prime-ish tile sizes so the repeat never reads as a grid. */
.stars {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
  background-image:
    radial-gradient(circle, rgb(244 230 207 / 0.5) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgb(183 169 212 / 0.45) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgb(244 230 207 / 0.35) 0 0.8px, transparent 1.3px);
  background-size: 331px 277px, 457px 389px, 211px 193px;
  background-position: 20px 40px, 140px 90px, 70px 10px;
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

.hero-inner {
  display: grid;
  --hero-gap: clamp(24px, 4vw, 64px);
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--hero-gap);
  align-items: center;
  max-width: var(--wrap);
  min-height: var(--hero-h);
  margin-inline: auto;
  padding: 16px var(--gutter) 56px;
}

.hero-copy {
  position: relative;
  z-index: 2;
  max-width: 34rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 5.2vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.hero h1 .line {
  display: block;
}

.ember-word {
  color: var(--color-coral);
  text-shadow: 0 0 24px rgb(241 139 128 / 0.35);
}

.lede {
  max-width: 34ch;
  margin-top: 24px;
  color: var(--text-secondary);
  font-size: clamp(1.0625rem, 1.4vw, 1.25rem);
  line-height: 1.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 36px;
}

/* The art spills into the column gap and page gutter: its padded backdrop is
   empty, so the moth itself stays clear of the text and the viewport edge. */
.hero-art {
  --art-ratio: 1257 / 1069;
  --fade-x: 6.5%;
  --fade-y: 8%;
  position: relative;
  z-index: 1;
  margin-left: calc(-1 * var(--hero-gap));
  margin-right: calc(-1 * var(--gutter));
}

.moth-frame {
  position: relative;
  width: min(100%, (var(--hero-h) - 48px) * var(--art-ratio));
  margin-inline: auto;
  animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    scale: 1.03;
  }
}

/* A soft lantern glow behind the moth that swells as it breathes. */
.moth-frame::before {
  content: "";
  position: absolute;
  inset: 8% 10%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 42%, rgb(241 139 128 / 0.32), rgb(183 169 212 / 0.14) 45%, transparent 72%);
  filter: blur(24px);
  animation: lantern 6s ease-in-out infinite;
}

@keyframes lantern {
  50% {
    opacity: 0.45;
    scale: 0.94;
  }
}

/* The fade dissolves the artwork's backdrop (a hair off Nightfall after
   compression) into the page, leaving no visible frame. */
.moth-frame img {
  width: 100%;
  --mask-x: linear-gradient(to right, transparent, #000 var(--fade-x), #000 calc(100% - var(--fade-x)), transparent);
  --mask-y: linear-gradient(to bottom, transparent, #000 var(--fade-y), #000 calc(100% - var(--fade-y)), transparent);
  -webkit-mask-image: var(--mask-x), var(--mask-y);
  -webkit-mask-composite: source-in;
  mask-image: var(--mask-x), var(--mask-y);
  mask-composite: intersect;
}

/* Glow halos pinned to the two painted eyespots, pulsing slowly. */
.eyespot-glow {
  position: absolute;
  top: 28.2%;
  width: 11%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(244 230 207 / 0.9) 0 10%, rgb(241 139 128 / 0.9) 22%, rgb(241 139 128 / 0.4) 42%, transparent 68%);
  opacity: 0.35;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: eyespot-pulse 3s ease-in-out infinite;
}

.eyespot-glow.is-left {
  left: 20.6%;
}

.eyespot-glow.is-right {
  left: 79.6%;
  animation-delay: -1.5s;
}

@keyframes eyespot-pulse {
  50% {
    opacity: 1;
    scale: 1.35;
  }
}

/* Embers drift in front of the moth but behind the text (see site.js). */
.embers {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.ember {
  position: absolute;
  bottom: -12px;
  left: var(--x);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--color-coral);
  box-shadow: 0 0 calc(var(--size) * 3) calc(var(--size) * 0.8) rgb(241 139 128 / 0.55);
  opacity: 0;
  animation:
    ember-rise var(--duration) linear var(--delay) infinite,
    ember-sway var(--sway) ease-in-out var(--delay) infinite alternate;
}

.ember.is-pale {
  background: var(--color-moonlight);
  box-shadow: 0 0 calc(var(--size) * 3) calc(var(--size) * 0.7) rgb(244 230 207 / 0.45);
}

@keyframes ember-rise {
  0% {
    translate: 0 0;
    opacity: 0;
  }
  12% {
    opacity: var(--glow);
  }
  75% {
    opacity: var(--glow);
  }
  100% {
    translate: 0 calc(-1 * var(--rise, 100vh));
    opacity: 0;
  }
}

@keyframes ember-sway {
  from {
    transform: translateX(calc(-1 * var(--drift)));
  }
  to {
    transform: translateX(var(--drift));
  }
}

/* ---------- Waypoints (dotted routes between sections) ---------- */

.waypoint {
  position: relative;
  width: 2px;
  height: clamp(56px, 8vw, 110px);
  margin-inline: auto;
  background: radial-gradient(circle, var(--dot) 0 1.2px, transparent 1.8px) center / 2px 12px repeat-y;
}

.waypoint::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 14px;
  height: 14px;
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-moonlight) 0 2px, var(--color-coral) 2.5px 5px, transparent 5.5px);
  box-shadow: 0 0 12px rgb(241 139 128 / 0.5);
}

/* ---------- Studio (light brand panel) ---------- */

.studio {
  padding: clamp(32px, 6vw, 96px) var(--gutter) 0;
}

.panel {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas:
    "logo copy"
    "legend legend";
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
  max-width: 1240px;
  margin-inline: auto;
  padding: clamp(32px, 6vw, 88px);
  border-radius: var(--radius-brand-card);
  background: var(--background);
  color: var(--text-primary);
  box-shadow: 0 30px 80px -40px rgb(244 230 207 / 0.25);
}

.studio-logo {
  grid-area: logo;
  justify-self: center;
  width: min(100%, 400px);
}

.studio-copy {
  grid-area: copy;
}

.studio h2 {
  font-size: clamp(2.25rem, 4.2vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.studio-copy p:not(.eyebrow) {
  max-width: 36em;
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 1.125rem;
}

.studio-copy h2 + p {
  margin-top: 24px;
}

/* Legend: the map key for how we make things. */
.legend {
  grid-area: legend;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 24px clamp(24px, 4vw, 56px);
  padding-top: clamp(28px, 4vw, 48px);
  border-top: 1px solid var(--rule);
}

.legend-title {
  font: 400 1.75rem/1.1 var(--font-display);
  letter-spacing: -0.01em;
}

.legend-sub {
  margin-top: 6px;
  color: var(--text-secondary);
  font: italic 400 1rem/1.4 var(--font-display);
}

.legend-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px clamp(20px, 3vw, 40px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.legend-list h4 {
  font: 400 1.375rem/1.2 var(--font-display);
  letter-spacing: -0.01em;
}

.legend-list p {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.legend-symbol {
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 1px;
}

.symbol-eyespot {
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--color-moonlight) 0 16%, var(--color-coral) 17% 52%, transparent 53%),
    radial-gradient(circle, transparent 0 66%, var(--color-plum) 67% 74%, transparent 75%);
}

.symbol-star {
  background: var(--color-plum);
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
}

.symbol-route {
  background:
    radial-gradient(circle, var(--color-coral) 0 3.5px, transparent 4px) right center / 9px 9px no-repeat,
    radial-gradient(circle, var(--color-plum) 0 1.4px, transparent 2px) left center / 6px 6px repeat-x;
  background-position: right center, left center;
  background-size: 9px 9px, 6px 28px;
  background-repeat: no-repeat, repeat-x;
  transform: rotate(-20deg);
}

/* ---------- Signals (follow the light) ---------- */

.signals {
  padding: clamp(32px, 6vw, 96px) var(--gutter) 0;
}

.signals-inner {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  max-width: 1240px;
  margin-inline: auto;
}

.signals h2 {
  font-size: clamp(2.25rem, 4.2vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.signals-copy > p:not(.eyebrow) {
  max-width: 36em;
  margin-top: 24px;
  color: var(--text-secondary);
  font-size: 1.125rem;
}

.signal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

/* Round icon buttons in the secondary-action treatment: Plum fill, Lilac rule. */
.icon-link {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgb(183 169 212 / 0.35);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  transition:
    translate 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.25s ease;
}

.icon-link svg {
  width: 22px;
  height: 22px;
}

@media (hover: hover) {
  .icon-link:hover {
    translate: 0 -2px;
    border-color: var(--color-lilac);
    color: var(--color-coral);
    box-shadow: 0 8px 22px -10px rgb(241 139 128 / 0.6);
  }
}

/* Expedition log: a plum card that reads like a ship's manifest. */
.log {
  position: relative;
  padding: clamp(24px, 3vw, 36px);
  border: 1px solid rgb(183 169 212 / 0.25);
  border-radius: var(--radius-brand-card);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgb(244 230 207 / 0.06), 0 24px 60px -30px rgb(0 0 0 / 0.6);
}

.log::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 14px;
  height: 14px;
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-moonlight) 0 2px, var(--color-coral) 2.5px 5px, transparent 5.5px);
  box-shadow: 0 0 12px rgb(241 139 128 / 0.5);
}

.log-title {
  font: 400 1.5rem/1.1 var(--font-display);
  letter-spacing: -0.01em;
}

.log-list {
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

.log-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px dashed rgb(196 186 204 / 0.25);
}

.log-list dt {
  color: var(--text-secondary);
}

.log-list dd {
  color: var(--text-primary);
  text-align: right;
}

.log-list dd[data-moth-status] {
  color: var(--color-coral);
}

.log-note {
  margin-top: 16px;
  color: var(--text-secondary);
  font: italic 400 0.9375rem/1.4 var(--font-display);
}

/* ---------- Contact ---------- */

.contact {
  max-width: 46rem;
  margin-inline: auto;
  padding: clamp(32px, 6vw, 96px) var(--gutter) clamp(80px, 12vw, 168px);
  text-align: center;
}

.contact-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.contact h2 {
  font-size: clamp(2.5rem, 5.5vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.contact-note {
  max-width: 38ch;
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 1.125rem;
}

.contact .button {
  margin-top: 36px;
}

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

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 28px var(--gutter) 40px;
  border-top: 1px solid var(--rule);
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ---------- Smaller screens ---------- */

@media (max-width: 959px) {
  .hero-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    min-height: 0;
    padding-top: 8px;
  }

  /* Headline first on small screens; the moth follows beneath it. */
  .hero-art {
    margin-inline: calc(-1 * var(--gutter));
    margin-top: 8px;
  }

  .moth-frame {
    width: min(100%, 60svh * var(--art-ratio));
  }

  .hero h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
  }

  .panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "logo"
      "copy"
      "legend";
  }

  .studio-logo {
    width: min(72%, 320px);
  }

  .legend {
    grid-template-columns: minmax(0, 1fr);
  }

  .signals-inner {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 719px) {
  :root {
    --header-h: 72px;
  }

  .brand-name {
    display: none;
  }

  .legend-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .embers {
    display: none;
  }

  .eyespot-glow {
    opacity: 0.25;
  }
}
