@layer reset, base, layout, components, motion;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
  ul, ol { padding: 0; list-style: none; }
  img { display: block; max-width: 100%; height: auto; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
  a { color: inherit; }
}

@layer base {
  :root {
    --bg: #131a22;
    --bg-2: #1a2330;
    --ink: #ece9e2;
    --ink-2: #a3a7ad;
    --oak: #e8891d;
    --walnut: #2b3a4a;
    --brand: #e8891d;
    --rule: color-mix(in oklab, var(--ink) 14%, transparent);

    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --sans: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;

    --step--1: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
    --step-0: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    --step-1: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
    --step-2: clamp(1.7rem, 1.4rem + 1.4vw, 2.6rem);
    --step-3: clamp(2.3rem, 1.6rem + 3vw, 4.4rem);
    --step-4: clamp(2.6rem, 1.3rem + 4.9vw, 6rem);

    --gutter: clamp(1.25rem, 4vw, 4rem);
    --section: clamp(5rem, 12vw, 11rem);
    color-scheme: dark;
  }

  html { scroll-behavior: smooth; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: var(--step-0);
    font-weight: 300;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
  }
  h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 300;
    line-height: 1.05;
    letter-spacing: -0.01em;
    text-wrap: balance;
    font-variation-settings: "opsz" 96;
  }
  h2 { font-size: var(--step-3); }
  h3 { font-size: var(--step-1); font-variation-settings: "opsz" 40; }
  p { max-width: 58ch; text-wrap: pretty; }
  a { text-decoration: none; }
  :focus-visible { outline: 2px solid var(--oak); outline-offset: 4px; }
  ::selection { background: var(--walnut); color: var(--ink); }

  .skip {
    position: absolute; inset-inline-start: 1rem; top: -4rem;
    background: var(--ink); color: var(--bg); padding: .5rem 1rem; z-index: 100;
  }
  .skip:focus { top: 1rem; }
}

@layer layout {
  .top {
    position: fixed; inset-inline: 0; top: 0; z-index: 20;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding: 1.1rem var(--gutter);
    color: var(--ink);
  }
  .brand { display: inline-flex; justify-self: start; }
  .logo { height: 1.85rem; width: auto; display: block; }
  .logo-mark { display: block; height: 2rem; width: auto; margin-bottom: 1rem; }
  .nav { display: flex; gap: 2.2rem; font-size: var(--step--1); letter-spacing: .02em; }
  .nav a { position: relative; padding-block: .25rem; }
  .nav a::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform .4s cubic-bezier(.7,0,.2,1); }
  .nav a:hover::after, .nav a:focus-visible::after { transform: scaleX(1); transform-origin: left; }
  .top-phone { justify-self: end; font-size: var(--step--1); font-variant-numeric: tabular-nums; }
  .burger { display: none; justify-self: end; width: 2.6rem; height: 2.6rem; position: relative; }
  .burger span, .burger span::before, .burger span::after {
    content: ""; position: absolute; left: .5rem; right: .5rem; height: 1px; background: currentColor; transition: transform .3s, top .3s;
  }
  .burger span { top: 50%; }
  .burger span::before { top: -6px; }
  .burger span::after { top: 6px; }
  .burger[aria-expanded="true"] span { background: transparent; }
  .burger[aria-expanded="true"] span::before { top: 0; transform: rotate(45deg); }
  .burger[aria-expanded="true"] span::after { top: 0; transform: rotate(-45deg); }

  .mobile-nav {
    position: fixed; inset: 0; z-index: 15; background: var(--bg);
    display: grid; align-content: center; gap: 1.2rem; padding: var(--gutter);
    font-family: var(--serif); font-size: var(--step-2);
  }
  .mobile-nav[hidden] { display: none; }

  main > section { padding-inline: var(--gutter); }

  /* Hero */
  .hero {
    position: relative; min-height: 100svh; display: grid; align-content: end;
    padding-block: var(--gutter); padding-inline: var(--gutter) !important;
    isolation: isolate;
  }
  .hero-media { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
  .hero-media img { width: 100%; height: 100%; object-fit: cover; object-position: 60% 50%; }
  .hero-media::after {
    content: ""; position: absolute; inset: 0;
    background:
      linear-gradient(to bottom, color-mix(in oklab, var(--bg) 60%, transparent), transparent 22%),
      linear-gradient(to top, var(--bg) 0%, color-mix(in oklab, var(--bg) 80%, transparent) 38%, color-mix(in oklab, var(--bg) 30%, transparent) 75%),
      linear-gradient(to right, color-mix(in oklab, var(--bg) 75%, transparent), color-mix(in oklab, var(--bg) 35%, transparent) 55%, transparent 80%);
  }
  .hero-text { max-width: 72rem; }
  .hero h1 { font-size: var(--step-4); font-weight: 400; font-variation-settings: "opsz" 72; }
  .hero h1 .line { display: block; overflow: hidden; padding-bottom: .22em; margin-bottom: -.22em; }
  .hero h1 .line > span { display: block; }
  .hero-sub { margin-top: 1.5rem; font-size: var(--step-1); color: var(--ink); max-width: 34ch; font-weight: 300; }
  .hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.2rem 2.2rem; margin-top: 2.2rem; }
  .hero-foot {
    display: flex; justify-content: space-between; gap: 1rem;
    margin-top: clamp(2rem, 6vw, 4rem); padding-top: 1rem; border-top: 1px solid var(--rule);
    font-size: var(--step--1); color: var(--ink-2);
  }

  /* Expanding panels */
  .panels {
    display: flex; gap: 4px; height: clamp(34rem, 78vh, 46rem);
    padding-inline: 4px !important; margin-top: 4px;
  }
  .panel {
    position: relative; flex: 1 1 0; min-width: 0; overflow: hidden;
    background: var(--bg-2) var(--img) center / cover no-repeat;
    display: grid; grid-template-rows: 1fr auto; isolation: isolate;
    transition: flex-grow .8s cubic-bezier(.7,0,.2,1);
  }
  .panel::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(to top, var(--bg) 0%, color-mix(in oklab, var(--bg) 40%, transparent) 45%, color-mix(in oklab, var(--bg) 35%, transparent) 100%);
    transition: opacity .8s;
  }
  .panel.is-open { flex-grow: 3.2; }
  .panel-head { display: block; text-align: left; padding: var(--gutter); align-self: end; width: 100%; }
  .panel-title {
    display: block; font-family: var(--serif); font-size: var(--step-3); font-weight: 300; line-height: 1;
    white-space: nowrap; font-variation-settings: "opsz" 144;
    transition: transform .8s cubic-bezier(.7,0,.2,1);
  }
  .panel:not(.is-open) .panel-title {
    writing-mode: vertical-rl; transform: rotate(180deg); font-size: var(--step-2); white-space: nowrap;
  }
  .panel:not(.is-open) .panel-head { align-self: stretch; display: grid; align-content: end; justify-content: start; }
  .panel-body {
    padding: 0 var(--gutter) var(--gutter);
    display: grid; gap: 1rem; max-width: 42rem;
    transition: opacity .5s .25s, translate .8s cubic-bezier(.7,0,.2,1);
  }
  .panel:not(.is-open) .panel-body { opacity: 0; translate: 0 1rem; pointer-events: none; position: absolute; inset-inline: 0; bottom: 0; }
  .panel-body p { color: var(--ink); }

  /* Story */
  .story {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--gutter);
    padding-block: var(--section);
  }
  .story-text { position: sticky; top: 20vh; align-self: start; }
  .story-text h2 { font-size: var(--step-3); margin-bottom: 1.5rem; max-width: 18ch; }
  .story-text p + p { margin-top: 1rem; }
  .story-text p { color: var(--ink-2); max-width: 46ch; }
  .story-media { display: grid; gap: clamp(2rem, 6vw, 5rem); }
  .story-media figure { display: grid; gap: .6rem; }
  .story-media figure:nth-child(2) { justify-self: end; width: 72%; }
  .story-media figure:nth-child(3) { width: 84%; }
  .story-media img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
  .story-media figure:nth-child(2) img { aspect-ratio: 4 / 5; }
  figcaption { font-size: var(--step--1); color: var(--ink-2); }

  /* Work strip */
  .work { padding-block: 0 var(--section); }
  .work-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
  .work-head p { color: var(--ink-2); }
  .strip {
    display: grid; grid-auto-flow: column; grid-auto-columns: min(78vw, 34rem); gap: 1.2rem;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter);
  }
  .strip::-webkit-scrollbar { display: none; }
  .strip figure { scroll-snap-align: start; display: grid; gap: .6rem; }
  .strip figure:nth-child(3n+2) { width: min(60vw, 22rem); align-self: center; }
  .strip button { display: block; width: 100%; }
  .strip img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: opacity .4s; }
  .strip button:hover img { opacity: .8; }
  .strip-nav { display: flex; gap: .5rem; margin-top: 1.5rem; }
  .strip-btn { width: 3rem; height: 3rem; border: 1px solid var(--rule); border-radius: 50%; display: grid; place-items: center; transition: border-color .3s, background .3s; }
  .strip-btn:hover { border-color: var(--oak); background: color-mix(in oklab, var(--oak) 12%, transparent); }

  /* Process */
  .process {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--gutter);
    padding-block: var(--section); border-top: 1px solid var(--rule);
  }
  .process-head { position: sticky; top: 20vh; align-self: start; }
  .process-head p { color: var(--ink-2); margin-top: 1rem; }
  .steps { display: grid; }
  .steps li {
    display: grid; grid-template-columns: 4rem 1fr; gap: 0 1.5rem; align-items: baseline;
    padding-block: 2rem; border-top: 1px solid var(--rule);
  }
  .steps li:last-child { border-bottom: 1px solid var(--rule); }
  .step-n { font-family: var(--serif); font-size: var(--step-3); font-weight: 300; color: var(--oak); line-height: 1; font-variation-settings: "opsz" 144; grid-row: span 2; }
  .steps h3 { margin-bottom: .5rem; }
  .steps p { color: var(--ink-2); }

  /* Materials */
  .materials {
    display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: var(--gutter);
    padding-block: var(--section); background: var(--bg-2);
    margin-inline: 4px; padding-inline: calc(var(--gutter) - 4px) !important;
  }
  .mat-corian h2 { max-width: 16ch; margin-bottom: 1.5rem; }
  .mat-corian p { color: var(--ink-2); }
  .mat-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 2rem; margin-top: 2rem; max-width: 40rem; }
  .mat-list li { padding-left: 1.2rem; position: relative; }
  .mat-list li::before { content: ""; position: absolute; left: 0; top: .7em; width: .5rem; height: 1px; background: var(--oak); }
  .mat-partners { border-left: 1px solid var(--rule); padding-left: var(--gutter); }
  .mat-partners h3 { color: var(--ink-2); font-family: var(--sans); font-size: var(--step--1); font-weight: 400; margin-bottom: 1.2rem; }
  .mat-partners ul { display: grid; gap: .4rem; font-family: var(--serif); font-size: var(--step-2); font-weight: 300; line-height: 1.15; }

  /* Studio */
  .studio {
    display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: var(--gutter); align-items: center;
    padding-block: var(--section);
  }
  .studio-media img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
  .studio-text h2 { max-width: 14ch; margin-bottom: 1.2rem; }
  .studio-lead { font-size: var(--step-1); font-weight: 300; }
  .contact { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 2rem; margin-top: 2rem; }
  .contact dt { font-size: var(--step--1); color: var(--ink-2); margin-bottom: .2rem; }
  .contact dd { font-variant-numeric: tabular-nums; }
  .contact a:hover { color: var(--oak); }

  .foot {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--gutter);
    padding: 2.5rem var(--gutter) 3rem; border-top: 1px solid var(--rule);
    font-size: var(--step--1); color: var(--ink-2); line-height: 1.7;
  }
  .foot strong { color: var(--ink); font-weight: 500; }
  .foot a:hover { color: var(--ink); }
  .foot-note { align-self: end; }

  @media (max-width: 900px) {
    .nav, .top-phone { display: none; }
    .burger { display: block; grid-column: 3; }
    .panels { flex-direction: column; height: auto; }
    .panel { min-height: 26rem; }
    .panel.is-open { flex-grow: 1; }
    .panel:not(.is-open) .panel-title { writing-mode: horizontal-tb; transform: none; font-size: var(--step-3); }
    .panel:not(.is-open) .panel-head { align-self: end; }
    .panel:not(.is-open) { min-height: 9rem; }
    .story, .process, .materials, .studio { grid-template-columns: 1fr; }
    .story-text, .process-head { position: static; }
    .story-media figure:nth-child(2), .story-media figure:nth-child(3) { width: 100%; justify-self: stretch; }
    .mat-partners { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 2rem; }
    .foot { grid-template-columns: 1fr; }
  }
  @media (max-width: 560px) {
    .mat-list, .contact { grid-template-columns: 1fr; }
    .hero-foot span:last-child { display: none; }
    .steps li { grid-template-columns: 2.6rem 1fr; }
  }
}

@layer components {
  .btn {
    display: inline-flex; align-items: center; gap: .6rem;
    padding: .95rem 1.6rem; border: 1px solid var(--ink);
    font-size: var(--step--1); letter-spacing: .02em; font-weight: 400;
    transition: background .35s, color .35s, border-color .35s;
  }
  .btn:hover, .btn:focus-visible { background: var(--ink); color: var(--bg); }
  .link { font-size: var(--step--1); letter-spacing: .02em; border-bottom: 1px solid var(--rule); padding-bottom: .15rem; transition: border-color .3s; }
  .link:hover { border-color: var(--ink); }

  .lightbox {
    border: 0; padding: 0; background: transparent; max-width: min(92vw, 1100px); max-height: 92vh;
    color: var(--ink);
  }
  .lightbox::backdrop { background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(6px); }
  .lightbox img { max-height: 82vh; width: auto; margin-inline: auto; }
  .lightbox-cap { text-align: center; margin-top: .8rem; color: var(--ink-2); font-size: var(--step--1); }
  .lightbox-close {
    position: absolute; top: -2.6rem; right: 0; font-size: 1.8rem; line-height: 1; width: 2.4rem; height: 2.4rem;
  }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    .hero h1 .line > span {
      translate: 0 130%;
      animation: rise 1.1s cubic-bezier(.2,.7,.2,1) forwards;
    }
    .hero h1 .line:nth-child(2) > span { animation-delay: .12s; }
    .hero h1 .line:nth-child(3) > span { animation-delay: .24s; }
    .hero-sub, .hero-actions, .hero-foot { opacity: 0; animation: fade 1s .6s ease forwards; }
    .hero-foot { animation-delay: .9s; }

    @supports (animation-timeline: scroll()) {
      .hero-media img { animation: drift linear both; animation-timeline: scroll(); animation-range: 0 100vh; }
    }
  }
  @keyframes rise { to { translate: 0 0; } }
  @keyframes fade { to { opacity: 1; } }
  @keyframes drift { from { scale: 1; translate: 0 0; } to { scale: 1.12; translate: 0 8%; } }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  }
}
