/* Baseline Technologies / Console
 * A showcase of current browser capabilities:
 *   oklch / light-dark / color-mix, @layer, CSS nesting,
 *   @property, @starting-style, subgrid, @container,
 *   scroll-driven animations, :has(), text-wrap, field-sizing.
 */

@layer reset, base, components, utilities;

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

@layer base {
  :root {
    color-scheme: light dark;

    --bg: light-dark(oklch(98% 0.003 250), oklch(15% 0.008 250));
    --surface: light-dark(oklch(95% 0.005 250), oklch(18% 0.01 250));
    --surface-hi: light-dark(oklch(92% 0.007 250), oklch(22% 0.012 250));
    --ink: light-dark(oklch(22% 0.01 250), oklch(94% 0.004 250));
    --mute: light-dark(oklch(50% 0.01 250), oklch(62% 0.01 250));
    --rule: light-dark(oklch(88% 0.01 250), oklch(28% 0.012 250));
    --rule-soft: light-dark(oklch(92% 0.007 250), oklch(22% 0.01 250));
    --accent: light-dark(oklch(52% 0.17 240), oklch(76% 0.12 220));
    --accent-2: light-dark(oklch(44% 0.18 150), oklch(76% 0.16 150));
    --danger: light-dark(oklch(55% 0.22 25), oklch(72% 0.2 25));

    --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

    --rail: 1200px;
    --gutter: clamp(16px, 3vw, 40px);
  }

  html {
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'kern', 'liga', 'calt', 'cv11';
  }

  body {
    background-color: var(--bg);
    background-image: radial-gradient(
      circle at 1px 1px,
      color-mix(in oklch, var(--ink) 8%, transparent) 1px,
      transparent 0
    );
    background-size: 32px 32px;
    color: var(--ink);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
  }

  p { text-wrap: pretty; }
  h1, h2, h3 { text-wrap: balance; font-weight: 600; letter-spacing: -0.01em; }

  a {
    text-decoration: none;
    border-bottom: 1px solid color-mix(in oklch, var(--accent) 50%, transparent);
    transition: border-color 180ms ease, color 180ms ease;

    &:hover, &:focus-visible {
      color: var(--accent);
      border-bottom-color: var(--accent);
      outline: none;
    }
  }

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

  .skip {
    position: absolute;
    left: -9999px;

    &:focus {
      left: 16px;
      top: 16px;
      background: var(--ink);
      color: var(--bg);
      padding: 8px 14px;
      z-index: 99;
    }
  }
}

@layer components {
  /* ── META STRIP ───────────────────────────────────── */

  @property --dot-mix {
    syntax: '<percentage>';
    initial-value: 0%;
    inherits: false;
  }

  .meta-strip {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border-bottom: 1px solid var(--rule);

    & .inner {
      max-width: var(--rail);
      margin: 0 auto;
      padding: 9px var(--gutter);
      display: flex;
      align-items: center;
      gap: 20px;
      font-family: var(--mono);
      font-size: 11px;
      letter-spacing: 0.08em;
      color: var(--mute);
      text-transform: uppercase;
      min-height: 34px;
    }

    & .status {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      color: var(--ink);
    }

    & .status-dot {
      --dot-mix: 0%;
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: color-mix(in oklch, var(--accent-2), oklch(95% 0.2 150) var(--dot-mix));
      box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent-2) calc(50% - var(--dot-mix) * 0.4), transparent);
      animation: dot-pulse 2.4s ease-in-out infinite;
    }

    & .grow { flex: 1; }

    & time { color: var(--ink); letter-spacing: 0.12em; }
  }

  @keyframes dot-pulse {
    0%, 100% { --dot-mix: 0%; box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent-2) 50%, transparent); }
    50% { --dot-mix: 80%; box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent-2) 0%, transparent); }
  }

  .scroll-progress {
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent);
    transform-origin: left;
    scale: 0 1;
    animation: scroll-progress linear;
    animation-timeline: scroll(root);
  }

  @keyframes scroll-progress {
    to { scale: 1 1; }
  }

  /* ── MASTHEAD ─────────────────────────────────────── */

  .rail {
    max-width: var(--rail);
    margin: 0 auto;
    padding: 0 var(--gutter);
  }

  .masthead {
    padding-block: clamp(64px, 10vw, 130px);
    position: relative;

    &::before {
      content: '';
      position: absolute;
      inset: 0;
      background: radial-gradient(
        ellipse 80% 60% at 20% 30%,
        color-mix(in oklch, var(--accent) 12%, transparent),
        transparent 60%
      );
      pointer-events: none;
      z-index: -1;
    }

    & .grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 40px;

      @media (min-width: 820px) {
        grid-template-columns: 1.4fr 1fr;
        gap: clamp(40px, 6vw, 80px);
      }
    }

    & .kicker {
      font-family: var(--mono);
      font-size: 11px;
      letter-spacing: 0.22em;
      text-transform: uppercase;
      color: var(--mute);
      margin-bottom: 20px;
    }

    & .wordmark {
      font-size: clamp(36px, 5vw, 60px);
      line-height: 1.04;
      letter-spacing: -0.02em;
      margin-bottom: 18px;
    }

    & .tagline {
      max-width: 44ch;
      font-size: clamp(16px, 1.4vw, 19px);
      color: var(--mute);
      line-height: 1.5;
    }

    & .spec-brief {
      display: grid;
      grid-template-columns: 100px 1fr;
      column-gap: 18px;
      row-gap: 10px;
      align-self: end;
      font-family: var(--mono);
      font-size: 12px;
      padding: 22px 0;
      border-top: 1px solid var(--rule);
      border-bottom: 1px solid var(--rule);

      & > div {
        display: contents;
      }

      & dt {
        color: var(--mute);
        text-transform: uppercase;
        letter-spacing: 0.16em;
        font-size: 10.5px;
        padding-top: 2px;
      }

      & dd {
        color: var(--ink);
      }
    }
  }

  /* ── SECTIONS ─────────────────────────────────────── */

  .bay {
    padding-block: clamp(56px, 8vw, 112px);
    border-top: 1px solid var(--rule);
    position: relative;

    animation: appear linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 25%;
  }

  @keyframes appear {
    from { opacity: 0; translate: 0 16px; }
    to { opacity: 1; translate: 0 0; }
  }

  .bay-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 48px;

    @media (min-width: 820px) {
      grid-template-columns: 1fr 1.4fr;
      gap: 40px;
      align-items: baseline;
    }

    & .section-title {
      font-size: clamp(26px, 3vw, 36px);
      line-height: 1.1;
      letter-spacing: -0.015em;
      display: flex;
      align-items: baseline;
      gap: 14px;
    }

    & .section-no {
      font-family: var(--mono);
      font-size: 11px;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      color: var(--mute);
      padding-top: 2px;
    }

    & .lede {
      max-width: 56ch;
      color: var(--mute);
      font-size: 16px;
      line-height: 1.55;
    }
  }

  /* ── SPEC LIST (subgrid for aligned columns) ──────── */

  .spec-list {
    display: grid;
    grid-template-columns: 96px 1fr 104px;
    column-gap: 28px;
    border-top: 1px solid var(--rule);

    @media (max-width: 640px) {
      grid-template-columns: 1fr;
      row-gap: 0;
    }
  }

  .spec-row {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    align-items: baseline;
    padding-block: 20px;
    border-bottom: 1px solid var(--rule);
    transition: background 200ms ease;

    &:hover {
      background: color-mix(in srgb, var(--surface), transparent 30%);
    }

    @media (max-width: 640px) {
      grid-template-columns: 1fr;
      row-gap: 8px;
    }

    & .id {
      font-family: var(--mono);
      font-size: 11px;
      letter-spacing: 0.14em;
      color: var(--mute);
      text-transform: uppercase;
      padding-top: 4px;
    }

    & .content {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    & h3 {
      font-size: 17.5px;
      line-height: 1.25;
      color: var(--ink);
      font-weight: 600;
    }

    & p {
      color: var(--mute);
      font-size: 15.5px;
      max-width: 68ch;
      line-height: 1.55;
    }

    & .tag {
      font-family: var(--mono);
      font-size: 10.5px;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--mute);
      padding: 3px 9px;
      border: 1px solid var(--rule);
      border-radius: 2px;
      justify-self: end;
      align-self: center;
      white-space: nowrap;

      @media (max-width: 640px) { justify-self: start; }
    }
  }

  /* ── PARTNERS ─────────────────────────────────────── */

  #partners {
    container-type: inline-size;
    container-name: partners;
  }

  .partner-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 48px;
  }

  @container partners (min-width: 720px) {
    .partner-grid {
      grid-template-columns: 1fr 1fr;
      gap: 56px;
    }
  }

  .partner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);

    & figure {
      width: 140px;
      height: 180px;
    }

    & img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      border: 1px solid var(--rule);
      filter: grayscale(25%) contrast(1.04);
    }

    & .name {
      font-size: clamp(22px, 2.2vw, 28px);
      line-height: 1.1;
      margin-bottom: 6px;
    }

    & .role {
      font-family: var(--mono);
      font-size: 11.5px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--mute);
      margin-bottom: 22px;
    }

    & dl {
      display: grid;
      grid-template-columns: 100px 1fr;
      column-gap: 18px;
      row-gap: 12px;
      font-family: var(--mono);
      font-size: 12.5px;

      & > div { display: contents; }
      & dt {
        color: var(--mute);
        letter-spacing: 0.12em;
        text-transform: uppercase;
        font-size: 10.5px;
        padding-top: 2px;
      }
      & dd { color: var(--ink); line-height: 1.55; }
    }
  }

  /* ── OFFICE ───────────────────────────────────────── */

  .office-specs {
    display: grid;
    grid-template-columns: 120px 1fr;
    column-gap: 28px;
    row-gap: 16px;
    font-family: var(--mono);
    font-size: 13px;
    padding-top: 4px;
    margin-bottom: 40px;

    & > div { display: contents; }
    & dt {
      color: var(--mute);
      letter-spacing: 0.16em;
      text-transform: uppercase;
      font-size: 11px;
      padding-top: 3px;
    }
    & dd { color: var(--ink); line-height: 1.6; }

    @media (max-width: 520px) {
      grid-template-columns: 1fr;
      & dt { padding-top: 10px; }
      & dt:first-of-type { padding-top: 0; }
    }
  }

  .actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
  }

  /* ── BUTTONS ──────────────────────────────────────── */

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;

    &:hover, &:focus-visible {
      background: color-mix(in oklch, var(--surface-hi), var(--accent) 8%);
      border-color: color-mix(in oklch, var(--rule), var(--accent) 40%);
    }
  }

  .btn-primary {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);

    &:hover, &:focus-visible {
      background: color-mix(in oklch, var(--ink), var(--accent) 25%);
      border-color: color-mix(in oklch, var(--ink), var(--accent) 25%);
    }
  }

  .btn-ghost {
    background: transparent;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--mute);
    transition: color 180ms, border-color 180ms;

    &:hover, &:focus-visible { color: var(--ink); border-color: var(--ink); }
  }

  /* ── DIALOG ───────────────────────────────────────── */

  dialog.contact-dialog {
    margin: auto;
    max-width: 540px;
    width: calc(100% - 32px);
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 0;
    box-shadow: 0 30px 60px -20px oklch(0% 0 0 / 0.4),
                0 0 0 1px color-mix(in oklch, var(--rule), transparent 60%);

    opacity: 1;
    translate: 0 0;
    transition:
      opacity 200ms ease,
      translate 200ms ease,
      overlay 200ms ease allow-discrete,
      display 200ms ease allow-discrete;

    &::backdrop {
      background: color-mix(in srgb, var(--bg) 40%, transparent);
      backdrop-filter: blur(12px) saturate(1.4);
      -webkit-backdrop-filter: blur(12px) saturate(1.4);
      opacity: 1;
      transition: opacity 200ms ease, overlay 200ms ease allow-discrete, display 200ms ease allow-discrete;
    }

    &:not([open]) {
      opacity: 0;
      translate: 0 8px;

      &::backdrop { opacity: 0; }
    }

    @starting-style {
      &[open] {
        opacity: 0;
        translate: 0 8px;

        &::backdrop { opacity: 0; }
      }
    }
  }

  .contact-form {
    display: grid;
    gap: 18px;
    padding: 24px 28px 28px;
  }

  .dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 4px;

    & h2 {
      font-size: 17px;
      font-weight: 600;
      letter-spacing: -0.005em;
    }
  }

  .field {
    display: grid;
    gap: 6px;

    & label {
      font-family: var(--mono);
      font-size: 10.5px;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      color: var(--mute);
    }

    & input, & select, & textarea {
      width: 100%;
      background: transparent;
      color: var(--ink);
      border: none;
      border-bottom: 1px solid var(--rule);
      padding: 8px 0 10px;
      font-family: var(--sans);
      font-size: 15px;
      line-height: 1.4;
      transition: border-color 180ms ease;
      border-radius: 0;

      &:focus {
        outline: none;
        border-bottom-color: var(--accent);
      }
    }

    & textarea {
      field-sizing: content;
      resize: vertical;
      min-height: 4lh;
      max-height: 14lh;
    }

    & select {
      appearance: none;
      background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%),
                         linear-gradient(-45deg, transparent 50%, var(--mute) 50%);
      background-position: calc(100% - 12px) center, calc(100% - 6px) center;
      background-size: 6px 6px;
      background-repeat: no-repeat;
      padding-right: 28px;
    }
  }

  .dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--rule);
    margin-top: 6px;
  }

  /* Disable submit until form is valid (CSS :has()) */
  form.contact-form:has(:invalid) .btn-primary {
    opacity: 0.45;
    pointer-events: none;
  }

  /* ── COLOPHON (footer) ────────────────────────────── */

  .colophon {
    border-top: 1px solid var(--rule);
    padding-block: 36px 48px;
    margin-top: clamp(40px, 6vw, 80px);
  }

  .colophon .inner {
    max-width: var(--rail);
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: grid;
    grid-template-columns: 80px 1fr;
    column-gap: 24px;
    row-gap: 10px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--mute);
    letter-spacing: 0.08em;

    & > div { display: contents; }
    & .k { text-transform: uppercase; letter-spacing: 0.18em; color: color-mix(in oklch, var(--mute), transparent 30%); }
    & a { color: var(--ink); border-bottom-color: var(--rule); }
    & a:hover { color: var(--accent); border-bottom-color: var(--accent); }
  }
}

@layer utilities {
  .mono { font-family: var(--mono); }
  .hidden { display: none !important; }
}

/* ── REDUCED MOTION ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
