/* Orthion Systems Inc.
   Two colours, two typefaces. Motion uses the browser's own scroll-driven
   animations and view transitions; where those are missing, or the visitor
   prefers reduced motion, everything is simply shown in place. */

@layer reset, tokens, base, layout, parts, motion;

/* ------------------------------------------------------------------ fonts */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2");
  font-weight: 500; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; 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, figure, ul, ol, dl, dd { margin: 0; }
  ul[class], ol[class] { padding: 0; list-style: none; }
  svg { display: block; max-width: 100%; }
  a { color: inherit; }
}

@property --head-ink { syntax: "<color>"; inherits: true; initial-value: #171717; }
@property --head-paper { syntax: "<color>"; inherits: true; initial-value: #F6F6F3; }

@layer tokens {
  :root {
    --ink: #171717;
    --paper: #F6F6F3;
    --quiet: color-mix(in oklab, var(--ink) 62%, var(--paper));
    --rule: color-mix(in oklab, var(--ink) 16%, var(--paper));

    --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    --gutter: clamp(1.25rem, 4.2vw, 4.5rem);
    --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
    --step-1: clamp(1.35rem, 1.2rem + 0.75vw, 1.9rem);
    --step-2: clamp(2.1rem, 1.35rem + 3.6vw, 4.6rem);
    --step-3: clamp(3.4rem, 1.6rem + 8.4vw, 9.5rem);

    color-scheme: light;
  }
}

@layer base {
  html { background: var(--paper); color: var(--ink); scroll-padding-top: 5rem; }
  body {
    font-family: var(--sans);
    font-size: var(--step-0);
    line-height: 1.55;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
  }
  ::selection { background: var(--ink); color: var(--paper); }
  .on-ink ::selection { background: var(--paper); color: var(--ink); }
  :focus-visible { outline: 2px solid currentColor; outline-offset: 5px; border-radius: 1px; }
  p { text-wrap: pretty; }
  h1, h2, h3 { font-weight: 500; text-wrap: balance; }

  .skip {
    position: fixed; inset-block-start: 0.75rem; inset-inline-start: 0.75rem; z-index: 20;
    padding: 0.6rem 0.9rem; background: var(--ink); color: var(--paper);
    transform: translateY(-200%);
  }
  .skip:focus { transform: none; }

  /* The small capitals of the logo's second row, reused for navigation and status. */
  .caps {
    font-family: var(--serif); font-weight: 600; font-size: 0.875rem;
    letter-spacing: 0.2em; text-transform: uppercase; line-height: 1.2;
  }
  .link {
    text-decoration: none;
    background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
    padding-block-end: 0.12em;
    transition: background-size 0.45s cubic-bezier(0.2, 0.7, 0.1, 1);
  }
  .link:hover { background-size: 0 1px; background-position-x: 100%; }
  .visually-hidden {
    position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
}

@layer layout {
  .wrap { padding-inline: var(--gutter); }
  .grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: clamp(1rem, 2vw, 2rem); }
}

@layer parts {
  /* ---------------------------------------------------------- site header */
  .site-head {
    position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
    padding: clamp(0.9rem, 1.8vw, 1.4rem) var(--gutter);
    color: var(--head-ink);
  }
  /* A soft-edged frosted band behind the header, so page text never collides with it. */
  .site-head::before {
    content: ""; position: absolute; inset: 0 0 -1.5rem 0; z-index: -1; pointer-events: none;
    background-color: color-mix(in oklab, var(--head-paper) 86%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    -webkit-mask-image: linear-gradient(to bottom, #000 58%, transparent);
    mask-image: linear-gradient(to bottom, #000 58%, transparent);
  }
  .site-mark { display: block; inline-size: clamp(7.5rem, 11vw, 9.5rem); }
  .site-mark svg { inline-size: 100%; block-size: auto; fill: currentColor; }
  .site-nav { display: flex; gap: clamp(1.25rem, 3vw, 2.75rem); }
  .site-nav a { text-decoration: none; padding-block: 0.4rem; }
  .site-nav a { transition: opacity 0.25s ease; }
  .site-nav a:hover { opacity: 0.55; }

  /* ----------------------------------------------------------------- hero */
  .hero {
    min-block-size: 100svh;
    display: grid; grid-template-rows: 1fr auto;
    padding-block: clamp(5rem, 12vh, 8rem) clamp(1.25rem, 3vh, 2.25rem);
  }
  .hero-mark { align-self: center; justify-self: center; inline-size: min(100%, 92rem); }
  .mark { inline-size: 100%; block-size: auto; overflow: visible; fill: var(--ink); touch-action: pan-y; }
  .mark-letter { transform-box: fill-box; transform-origin: center; }
  .hero-foot {
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem 2rem; flex-wrap: wrap;
    color: var(--quiet);
  }
  .hero-foot p:first-child { color: var(--ink); }

  /* ------------------------------------------------------------ statement */
  .statement {
    position: relative; align-items: start;
    padding-block: clamp(6rem, 22vh, 15rem);
    --leader: clamp(2.25rem, 5.5vw, 6rem);
  }
  .statement-lead {
    grid-column: 2 / span 10;
    font-family: var(--serif); font-weight: 500; font-size: var(--step-2);
    line-height: 1.04; letter-spacing: -0.015em; max-inline-size: 14em;
  }
  .statement-body {
    grid-column: 2 / span 6;
    margin-block-start: clamp(2.75rem, 8vh, 5.5rem);
    font-family: var(--serif); font-weight: 500;
    font-size: clamp(1.35rem, 1.05rem + 1vw, 2rem); line-height: 1.45;
  }
  .statement-body p { hanging-punctuation: first; }
  .statement-body p + p { margin-block-start: 1.1em; }

  /* Key phrases are underlined, and each has a note in the margin, drawn out to it
     by a fine leader line. The note sits level with its phrase (anchor positioning);
     without that, the notes follow the text as a short list. */
  .phrase { background: linear-gradient(var(--ink), var(--ink)) no-repeat 0 92% / 100% 1px; }
  .note {
    grid-column: 8 / span 4;
    font-size: 0.9375rem; line-height: 1.4; color: var(--quiet);
  }
  .note b {
    display: block; margin-block-end: 0.2rem;
    font-family: var(--serif); font-weight: 600; font-size: 0.8125rem;
    letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink);
    font-variant-numeric: lining-nums;
  }
  @supports (anchor-name: --a) {
    .note { position: absolute; inset-block-start: anchor(top); padding-inline-start: var(--leader); }
    /* Level with its phrase, but never higher than just below the note before it, so
       on wide screens, where the phrases fall on neighbouring lines, the notes step
       down instead of crowding. */
    .note ~ .note { inset-block-start: max(anchor(top), calc(anchor(var(--after) bottom) + 0.85rem)); }
    .note::before {
      content: ""; position: absolute; inset-inline-start: 0; inset-block-start: 0.55rem;
      inline-size: calc(var(--leader) - 0.9rem); border-block-start: 1px solid var(--ink);
      transform-origin: left;
    }
  }
  @supports not (anchor-name: --a) {
    .note { grid-column: 2 / span 6; margin-block-start: 1.5rem; }
  }

  /* ------------------------------------------------------------- products */
  .products { padding-block-end: clamp(5rem, 16vh, 11rem); }
  .product {
    border-block-start: 1px solid var(--rule);
    padding-block: clamp(2.5rem, 7vh, 5rem) clamp(4rem, 12vh, 8rem);
    row-gap: 3rem; align-items: start;
  }
  .product-text { grid-column: 1 / span 5; }
  .product-name {
    font-family: var(--serif); font-weight: 500; font-size: var(--step-3);
    line-height: 0.92; letter-spacing: -0.03em;
    margin-block-end: clamp(1.25rem, 3vh, 2.25rem);
  }
  .product-line {
    font-family: var(--serif); font-weight: 500; font-style: italic; font-size: var(--step-1);
    line-height: 1.2; max-inline-size: 18em; margin-block-end: 1.25rem;
  }
  .product-body { max-inline-size: 34em; color: var(--quiet); }
  .product-status { margin-block-start: clamp(1.75rem, 4vh, 2.75rem); }
  .product-figure { grid-column: 6 / -1; align-self: center; padding-inline-start: clamp(0rem, 3vw, 3.5rem); }
  .product-figure svg { inline-size: 100%; block-size: auto; overflow: visible; }
  .product-figure figcaption { margin-block-start: 1rem; font-size: 0.875rem; color: var(--quiet); max-inline-size: 36em; }
  .fig-line { fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linecap: square; }
  .fig-fine { fill: none; stroke: var(--ink); stroke-width: 0.8; }
  .fig-bar { fill: var(--ink); }
  .fig-text { font-family: var(--sans); font-size: 12.5px; fill: var(--quiet); font-variant-numeric: tabular-nums; }
  .fig-text--ink { fill: var(--ink); }

  /* -------------------------------------------------------------- contact */
  .contact {
    background: var(--ink); color: var(--paper);
    padding-block: clamp(6rem, 20vh, 13rem) clamp(1.5rem, 4vh, 2.5rem);
    --quiet: color-mix(in oklab, var(--paper) 62%, var(--ink));
    --rule: color-mix(in oklab, var(--paper) 20%, var(--ink));
  }
  .contact-lede {
    grid-column: 2 / span 9;
    font-family: var(--serif); font-weight: 500; font-size: var(--step-2);
    line-height: 1.08; letter-spacing: -0.012em; max-inline-size: 19em;
  }
  .contact-way { grid-column: 2 / span 10; margin-block-start: clamp(3rem, 9vh, 6rem); }
  .contact-way dt { color: var(--quiet); margin-block-end: 0.6rem; }
  .contact-way dd { font-family: var(--serif); font-weight: 500; font-size: var(--step-1); line-height: 1.2; overflow-wrap: anywhere; }
  .end-mark { margin-block-start: clamp(5rem, 17vh, 11rem); }
  .end-mark .mark { fill: var(--paper); }
  .site-foot {
    margin-block-start: clamp(3rem, 9vh, 5.5rem);
    padding-block-start: 1.5rem; border-block-start: 1px solid var(--rule);
    display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem 2rem; flex-wrap: wrap;
    font-size: 0.875rem; color: var(--quiet);
  }
  .site-foot a { color: var(--paper); }

  /* ----------------------------------------------------------- prose page */
  .page { padding-block: clamp(8rem, 22vh, 13rem) clamp(5rem, 14vh, 9rem); }
  .page-title {
    grid-column: 2 / span 10;
    font-family: var(--serif); font-size: var(--step-3); line-height: 0.92; letter-spacing: -0.03em;
  }
  .page-meta { grid-column: 2 / span 10; margin-block-start: 1.5rem; color: var(--quiet); }
  .prose { grid-column: 2 / span 7; margin-block-start: clamp(3rem, 9vh, 6rem); max-inline-size: 40em; }
  .prose h2 {
    font-family: var(--serif); font-size: var(--step-1); line-height: 1.2;
    margin-block: 2.75em 0.6em;
  }
  .prose p + p, .prose ul + p, .prose p + ul { margin-block-start: 1em; }
  .prose ul { padding-inline-start: 1.1em; }
  .prose li + li { margin-block-start: 0.4em; }
  .prose .lede { font-family: var(--serif); font-size: var(--step-1); line-height: 1.3; }
  .page-foot { border-block-start: 1px solid var(--rule); }
  .page-foot .site-foot { margin-block-start: 0; border: 0; padding-block: 1.5rem; }
  .page-foot .site-foot a { color: var(--ink); }

  @media (max-width: 54rem) {
    .statement-lead, .statement-body, .contact-lede, .contact-way, .page-title, .page-meta, .prose { grid-column: 1 / -1; }
    .statement .note { position: static; grid-column: 1 / -1; padding: 0; margin-block-start: 1.5rem; }
    .statement .note::before { display: none; }
    .product-text, .product-figure { grid-column: 1 / -1; }
    .product-figure { padding-inline-start: 0; }
    .product { padding-block-start: 2.25rem; }
    .hero-mark { inline-size: 100%; }
  }
}

@layer motion {
  @view-transition { navigation: auto; }
  .site-mark { view-transition-name: site-mark; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.45s; }

  /* Smooth wheel scrolling (smooth-scroll.js, Lenis). While it runs, it moves the page
     itself, so the browser's own smooth scrolling is turned off to keep out of its way. */
  html.lenis, html.lenis body { height: auto; }
  .lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
  .lenis [data-lenis-prevent] { overscroll-behavior: contain; }

  @media (prefers-reduced-motion: no-preference) {
    html:not(.lenis) { scroll-behavior: smooth; }

    /* Hero: the script sets the letters askew, fades the mark in, then lets them settle. */
    .js .hero .mark { opacity: 0; transition: opacity 0.7s ease; }
    .js .hero .mark.is-shown { opacity: 1; }
    .js .hero .mark-letter { will-change: transform; }
    .js .hero-foot { opacity: 0; transition: opacity 1.1s ease 1.9s; }
    .js .hero.is-settled .hero-foot { opacity: 1; }

    @supports (animation-timeline: view()) {
      /* The small mark in the header arrives as the large one leaves. */
      .home .site-mark {
        animation: appear linear both;
        animation-timeline: scroll(root block);
        animation-range: 55vh 90vh;
      }

      /* Over the ink section the header takes the ink colours. */
      body { timeline-scope: --contact; }
      .contact { view-timeline: --contact block; view-timeline-inset: 2.4rem 0; }
      .home .site-head {
        animation: head-on-ink linear both;
        animation-timeline: --contact;
        animation-range: exit-crossing 0% exit-crossing 1.2%;
      }

      /* The closing wordmark comes true as it enters. */
      .end-mark { view-timeline: --end block; }
      .end-mark .mark-letter {
        animation: true-up linear both;
        animation-timeline: --end;
        animation-range: entry 0% entry 105%;
      }

      /* The statement inks in, word by word, as it crosses the screen. */
      .statement-lead { view-timeline: --statement block; }
      .statement .w {
        animation: ink linear both;
        animation-timeline: --statement;
        animation-range: cover calc(14% + var(--i) * 2.6%) cover calc(26% + var(--i) * 2.6%);
      }

      /* Each key phrase is underlined as it is read, and its note is drawn out to the margin. */
      .phrase {
        view-timeline: --phrase block;
        animation: underline linear both; animation-timeline: --phrase;
        animation-range: cover 34vh cover 44vh;
      }
      .note {
        view-timeline: --note block;
        animation: appear linear both; animation-timeline: --note;
        animation-range: cover 36vh cover 46vh;
      }
      .note::before {
        animation: leader linear both; animation-timeline: --note;
        animation-range: cover 34vh cover 44vh;
      }

      /* The two drawings are drawn by the scroll. */
      .product-figure { view-timeline: --figure block; }
      .draw {
        stroke-dasharray: 1; stroke-dashoffset: 1;
        animation: draw linear both;
        animation-timeline: --figure;
        animation-range: cover calc(8% + var(--o) * 3.2%) cover calc(24% + var(--o) * 3.2%);
      }
      .grow {
        transform-box: fill-box; transform-origin: 0 50%;
        animation: grow linear both;
        animation-timeline: --figure;
        animation-range: cover calc(12% + var(--o) * 3.2%) cover calc(30% + var(--o) * 3.2%);
      }
      .fade {
        animation: appear linear both;
        animation-timeline: --figure;
        animation-range: cover calc(14% + var(--o) * 3.2%) cover calc(24% + var(--o) * 3.2%);
      }
    }
  }

  @keyframes head-on-ink { to { --head-ink: #F6F6F3; --head-paper: #171717; } }
  @keyframes true-up { from { transform: translate(var(--x), var(--y)) rotate(var(--r)); } to { transform: none; } }
  @keyframes appear { from { opacity: 0; } to { opacity: 1; } }
  @keyframes ink { from { opacity: 0.13; } to { opacity: 1; } }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes underline { from { background-size: 0% 1px; } to { background-size: 100% 1px; } }
  @keyframes leader { from { transform: scaleX(0); } to { transform: scaleX(1); } }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  }
}
