/* Ellse Labs company site. Static CSS, no build step.
   One system: every size and gap below comes from the tokens in the `tokens` layer, and the home
   screen and all four sections share one page template. Preview trial, not an approved brand:
   Space Grotesk / Geist / Newsreader italic; carbon, porcelain, electric indigo, cool silver. */

@layer reset, tokens, base, layout, components, stage;

@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/fonts/space-grotesk-variable.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-italic-variable.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body,
  h1,
  h2,
  h3,
  p,
  ol,
  ul {
    margin: 0;
    padding: 0;
  }
  ol,
  ul {
    list-style: none;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
  button {
    font: inherit;
    color: inherit;
  }
}

@layer tokens {
  :root {
    /* Tier 1: literal values */
    --carbon: #15171c;
    --porcelain: #f7f7f5;
    --indigo: #565cf5;
    --silver: #adb4c2;
    --slate: #565c69; /* legible secondary text on porcelain; silver is too pale for it */
    --indigo-soft: #9a9eff; /* legible accent on carbon; the indigo is too dark for small text there */

    /* Type scale: font-relative with a viewport part, each maximum at most 2.5× its minimum, so
       browser zoom can still double the text. */
    --step-display: clamp(2.5rem, 1.85rem + 2.67vw, 4.25rem); /* every page headline: 40px on a phone to 68px on a desktop */
    --step-label: clamp(1.875rem, 1.55rem + 1.33vw, 2.75rem); /* the four section names: 30px to 44px */
    --step-title: clamp(1.375rem, 1.28rem + 0.38vw, 1.625rem); /* item titles: 22px to 26px */
    --step-lead: clamp(1.25rem, 1.11rem + 0.57vw, 1.625rem); /* supporting copy: 20px on a phone to 26px on a desktop */
    --step-body: clamp(1.0625rem, 1.02rem + 0.19vw, 1.1875rem); /* running text: 17px to 19px */
    --step-meta: 0.9375rem; /* header, footer, labels, controls */

    /* Spacing scale */
    --space-1: 0.5rem;
    --space-2: 0.75rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
    --space-6: 3rem;
    --space-7: 4.5rem;
    --gutter: clamp(1.25rem, 0.7rem + 2.6vw, 3rem);
    --col-gap: clamp(2rem, 1rem + 4vw, 5rem);
    --row-label: 2.75rem; /* the label row above every headline, and the size of the back control */
    --measure: 60ch;

    /* Tier 2: semantic */
    --font-display: "Space Grotesk", "Geist", ui-sans-serif, system-ui, sans-serif;
    --display-weight: 500; /* medium: one weight for every page headline */
    --display-tracking: -0.03em;
    --display-features: normal;
    --font-accent: "Newsreader", Georgia, "Times New Roman", serif; /* the italic of "labs" */
    --font-body: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

    color-scheme: light dark;
    --bg: var(--porcelain);
    --fg: var(--carbon);
    --dim: var(--slate);
    --accent: var(--indigo);
    --line: rgba(21, 23, 28, 0.14);
    --raised: #ffffff;
  }
  @supports (color: light-dark(#000, #fff)) {
    :root {
      --bg: light-dark(var(--porcelain), var(--carbon));
      --fg: light-dark(var(--carbon), var(--porcelain));
      --dim: light-dark(var(--slate), var(--silver));
      --accent: light-dark(var(--indigo), var(--indigo-soft));
      --line: light-dark(rgba(21, 23, 28, 0.14), rgba(247, 247, 245, 0.18));
      --raised: light-dark(#ffffff, #1f232b);
    }
  }
  /* The theme control writes <meta name="color-scheme">; map it back so the cascade follows. */
  :root:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  :root:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }
}

@layer base {
  html {
    scroll-padding-top: var(--space-3);
  }
  body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: var(--step-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: clip;
  }
  h1,
  h2 {
    font-family: var(--font-display);
    font-weight: var(--display-weight);
    font-feature-settings: var(--display-features);
    font-size: var(--step-display);
    line-height: 1.06;
    letter-spacing: var(--display-tracking);
    max-width: 14ch;
    text-wrap: balance;
  }
  h3 {
    font-family: var(--font-display);
    font-weight: 500;
    font-feature-settings: var(--display-features);
    font-size: var(--step-title);
    line-height: 1.15;
    letter-spacing: -0.025em;
  }
  p {
    text-wrap: pretty;
  }
  a:focus-visible,
  button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
  }
  ::selection {
    background: color-mix(in srgb, var(--indigo) 28%, transparent);
  }
  .skip {
    position: absolute;
    left: var(--gutter);
    top: -4rem;
    z-index: 50;
    padding: var(--space-2) var(--space-3);
    background: var(--fg);
    color: var(--bg);
    font-size: var(--step-meta);
  }
  .skip:focus {
    top: var(--space-2);
  }
}

@layer layout {
  /* Header and footer: the same utility size everywhere. */
  .masthead,
  .colophon {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-3) var(--gutter);
    font-size: var(--step-meta);
  }
  .colophon {
    color: var(--dim);
  }

  /* One page template, used by the home screen and every section:
       row 1  a label row (the section name, and the back control in stage mode)
       row 2  the headline on the left, the content on the right
     On narrow screens the two columns stack, in the same order. */
  .home,
  .band {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--row-label) auto;
    align-content: start;
    gap: var(--space-4) var(--col-gap);
    padding: var(--space-3) var(--gutter) var(--space-7);
  }
  .band {
    border-top: 1px solid var(--line);
  }
  .home > .intro,
  .band > h2 {
    grid-row: 2;
  }
  .band > .label,
  .band > .sheet-top {
    grid-row: 1;
    align-self: center;
  }
  .home > :not(.intro),
  .band > :not(.label, .sheet-top, h2) {
    grid-row: 3;
  }
  @media (min-width: 60rem) {
    .home,
    .band {
      grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    }
    .home > :not(.intro),
    .band > :not(.label, .sheet-top, h2) {
      grid-column: 2;
      grid-row: 2;
    }
  }
}

@layer components {
  .brand {
    display: inline-flex;
  }
  /* The wordmark is drawn, not typeset: thin capitals for ELLSE, a light italic for labs. It is
     two pieces, the first E and the rest, so the intro can unfold the rest from the E. */
  .wordmark {
    display: inline-flex;
    align-items: flex-end;
    white-space: nowrap;
  }
  .wordmark svg {
    display: block;
    block-size: 1.625rem;
    inline-size: auto;
  }
  .wm-tail {
    display: block;
    overflow: hidden;
  }
  .sections ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
    color: var(--dim);
  }
  .sections a {
    display: inline-block;
    padding-block: var(--space-1);
  }
  .sections a:hover {
    color: var(--fg);
  }

  .label {
    font-size: var(--step-meta);
    font-weight: 500;
    color: var(--dim);
  }
  .lede,
  .prose,
  .reach {
    font-size: var(--step-lead);
    line-height: 1.55;
  }
  .lede {
    max-width: 38ch;
    margin-top: var(--space-4);
  }
  .prose {
    display: grid;
    gap: var(--space-5);
    max-width: var(--measure);
  }
  .reach {
    display: grid;
    gap: var(--space-4);
    max-width: var(--measure);
  }
  .contact-line {
    font-family: var(--font-display);
    font-weight: 500;
    font-feature-settings: var(--display-features);
    font-size: var(--step-title);
    line-height: 1.1;
    letter-spacing: var(--display-tracking);
    overflow-wrap: anywhere;
  }
  .contact-line a {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 0.07em;
    text-underline-offset: 0.16em;
    transition: color 0.2s ease;
  }
  .contact-line a:hover {
    color: var(--accent);
  }

  .lost {
    display: grid;
    align-content: center;
    gap: var(--space-4);
    min-height: 70vh;
    padding: var(--space-6) var(--gutter);
  }
  .lost a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  /* Preview-only controls: navigation design and theme. */
  .switch {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-1) var(--space-2);
    color: var(--dim);
  }
  .switch button {
    min-height: 2.25rem;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: 999px;
    background: none;
    cursor: pointer;
  }
  /* The header controls: two round icon buttons, theme and replay. */
  .switch .theme,
  .switch .replay {
    display: grid;
    place-items: center;
    width: 2.5rem;
    min-height: 2.5rem;
    padding: 0;
    border: 1px solid var(--line);
    color: var(--fg);
  }
  .switch svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  @media (hover: hover) {
    .switch .theme:hover,
    .switch .replay:hover {
      background: var(--fg);
      color: var(--bg);
    }
  }
  @media (max-width: 47.99rem) {
    .switch button {
      padding: 0 var(--space-2);
    }
    .switch .theme,
    .switch .replay {
      padding: 0;
    }
  }

  /* The intro: the wordmark starts large in the middle of the screen over a plain cover, then
     docks into the header as the cover clears. site.js drives it; nothing here moves by itself. */
  .intro-cover {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--fg);
    pointer-events: none;
  }
  /* The print itself: a copy of the wordmark drawn over the real one during the intro. */
  .intro-print {
    position: fixed;
    z-index: 44;
    color: var(--bg);
    transform-origin: 0 50%;
    pointer-events: none;
  }
  /* The flip: a soft disc of the page's own background that grows from the name until it fills
     the screen. Only its position, size and opacity change, so nothing is repainted as it moves. */
  .intro-fx {
    position: fixed;
    z-index: 42;
    pointer-events: none;
  }
  .intro-glow {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0;
    background: radial-gradient(closest-side, var(--bg) 40%, color-mix(in oklab, var(--bg) 55%, transparent) 66%, transparent);
  }
  /* The print head: a soft glow at the point where the current layer is being laid down. */
  .intro-nozzle {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 45;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    border-radius: 50%;
    color: var(--bg);
    background: radial-gradient(closest-side, color-mix(in oklab, currentColor 40%, transparent), transparent);
    pointer-events: none;
  }
  .intro-on .brand {
    position: relative;
    z-index: 43;
  }
  .intro-on .wordmark {
    transform-origin: 0 50%;
  }

  /* The 2×2 */
  .grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(9rem, 1fr));
  }
  .cell {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-4);
    overflow: hidden;
  }
  .cell-label {
    font-family: var(--font-display);
    font-weight: var(--display-weight);
    font-feature-settings: var(--display-features);
    font-size: var(--step-label);
    line-height: 1.05;
    letter-spacing: var(--display-tracking);
    /* The four section names take the italic of "labs" in the wordmark. */
    font-family: var(--font-accent);
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.01em;
  }
  .cell-hint {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    height: 2.9em; /* always two lines tall, so the four labels sit at the same height */
    overflow: hidden;
    font-size: var(--step-meta);
    line-height: 1.45;
    color: var(--dim);
    opacity: 0;
    transform: translateY(0.4rem);
    transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), color 0.3s ease;
  }
  .cell:hover .cell-hint,
  .cell:focus-visible .cell-hint {
    opacity: 1;
    transform: none;
  }
  @media (hover: none) {
    .cell-hint {
      opacity: 1;
      transform: none;
    }
  }
  /* Phones: the tiles are too narrow for the hint, so they carry the section name alone. */
  @media (max-width: 47.99rem) {
    .cell-hint {
      display: none;
    }
  }
  .cell:focus-visible {
    outline-offset: -4px;
    border-radius: 0;
  }

  /* The quadrants: one seamless block divided by hairlines */
  [data-nav="a"] .grid {
    border: 1px solid var(--line);
  }
  [data-nav="a"] .cell {
    transition: background-color 0.35s ease, color 0.35s ease;
  }
  [data-nav="a"] .cell:nth-child(odd) {
    border-right: 1px solid var(--line);
  }
  [data-nav="a"] .cell:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
  [data-nav="a"] .cell::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  @media (hover: hover) {
    [data-nav="a"] .cell:hover {
      background: var(--fg);
      color: var(--bg);
    }
    [data-nav="a"] .cell:hover .cell-hint {
      color: color-mix(in srgb, var(--bg) 72%, var(--fg));
    }
    [data-nav="a"] .cell:hover::after {
      transform: scaleX(1);
    }
  }
  [data-nav="a"] .cell:focus-visible::after {
    transform: scaleX(1);
  }

  /* Touch screens: no grey flash on tap and no hover state left behind. A tile turns dark
     while the finger is down, the same color change a mouse hover gives. */
  a,
  button {
    -webkit-tap-highlight-color: transparent;
  }
  @media (hover: none) {
    [data-nav="a"] .cell {
      transition: background-color 0.12s ease, color 0.12s ease;
    }
    [data-nav="a"] .cell:active {
      background: var(--fg);
      color: var(--bg);
    }
    /* The blue bar across the top of the tile arrives at once on touch; on a mouse it draws
       across more slowly. */
    [data-nav="a"] .cell::after {
      transition-duration: 0.14s;
    }
    [data-nav="a"] .cell:active::after {
      transform: scaleX(1);
    }
    .back:active,
    .switch button:active {
      background: var(--line);
    }
  }
  /* The tile that was chosen keeps the same dark state as a mouse hover while its section
     opens, so a tap shows a clear color change on every kind of screen. */
  [data-nav="a"] .cell.picked {
    background: var(--fg);
    color: var(--bg);
  }
  [data-nav="a"] .cell.picked::after {
    transform: scaleX(1);
  }
  /* After a tap, the tile that gets focus back stays quiet; keyboard users still get the ring. */
  [data-input="touch"] .cell:focus-visible,
  [data-input="touch"] .band:focus-visible {
    outline: none;
  }
  [data-input="touch"] .cell:focus-visible::after {
    transform: scaleX(0);
  }

  .sheet-top {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }
  .back {
    display: grid;
    place-items: center;
    width: var(--row-label);
    height: var(--row-label);
    margin-left: -0.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    transition: background-color 0.25s ease;
  }
  @media (hover: hover) {
    .back:hover {
      background: var(--line);
    }
  }
  .back svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

/* Stage mode. site.js adds .stage to <html> when motion is welcome: the page becomes one screen,
   the home screen holds the 2×2, and choosing a section opens it in place of the home screen.
   The template, sizes and spacing are exactly the ones above; only the scrolling changes.
   Sections scroll inside the screen when they are taller than it. */
@layer stage {
  html.stage,
  .stage body {
    height: 100%;
    overflow: hidden;
  }
  .stage body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }
  .stage .masthead,
  .stage .colophon {
    flex: none;
  }
  .stage .sections {
    display: none;
  }
  .stage main {
    position: relative;
    flex: 1;
    min-height: 0;
    perspective: 1800px;
  }
  .stage .home,
  .stage .band {
    position: absolute;
    inset: 0;
    border-top: 0;
    padding-bottom: var(--space-5);
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg);
  }
  .stage .home {
    grid-template-rows: var(--row-label) minmax(0, 1fr);
  }
  .stage .band {
    z-index: 2;
    visibility: hidden;
    backface-visibility: hidden;
    outline: none;
  }
  .stage .band.open {
    visibility: visible;
  }
  @media (max-width: 59.99rem) {
    .stage .home {
      /* On narrow screens the empty label row above the headline shrinks, so the four tiles fit. */
      grid-template-rows: var(--space-3) auto minmax(14rem, 1fr);
    }
  }
}

@media print {
  .sections,
  .switch,
  .skip {
    display: none;
  }
}
