/*
 * CIAN marketing site.
 *
 * One stylesheet, no build step, no framework. Written to be legible in both
 * colour schemes and usable with a keyboard and a screen reader — non-technical
 * UAT approvers are an intended audience, so this is a requirement rather than
 * a finishing touch.
 *
 * Layout is fluid rather than breakpoint-driven where possible (clamp() for
 * type, auto-fit grids for cards), so there is no width at which the page is
 * merely "not broken" instead of actually laid out.
 *
 * Tokens below are sourced from "CIAN iPad — UI Guidelines (v1.2)" (Linear,
 * project CIAN Code Factory) for surfaces/type, and the brand palette from
 * SHA-814 (brand identity asset pack) for the identity accent — the actual
 * product's own systems, not an invented palette. The design decisions that
 * shape this file:
 *
 *   - Night is the default, not a theme. The product ships no light mode at
 *     all; this site still needs one (non-technical visitors, OS-level
 *     preference), so dark is the base :root here and light is the override —
 *     inverted from the usual convention — with a light palette derived from
 *     the same hue family rather than a generic invert.
 *   - Rust is the brand accent; state colours stay reserved. SHA-814 makes
 *     Rust (#c94436) the identity colour — the mark's primary strand and the
 *     wordmark accent — and is emphatic that it is NOT the alert crimson
 *     (#b03449 → BLOCKED). So Rust carries interactive chrome and brand
 *     moments (links, focus, the mark, eyebrows), while the UI Guidelines'
 *     HEALTHY / AWAITING / BLOCKED colours stay reserved for the site's real
 *     state UI (status tags, the legal-draft banner, form validation). The
 *     two vocabularies do not overlap, which is the whole point of SHA-814's
 *     "not the crimson" rule.
 *   - No colour-filled buttons. A primary action is a brighter surface and a
 *     stronger border, never a solid accent fill (UI Guidelines, Principle 7).
 *
 * Surface/text/border hexes are the source doc's exact values. Rust is used
 * verbatim (#c94436) for the mark and other graphics — where 3:1 is the bar —
 * and lightened (dark) or deepened to Rust Deep (light) for link-sized text,
 * where the canonical value falls just short of the 4.5:1 AA floor. State
 * colours are re-derived brighter than the doc's dot/border values because
 * that doc calibrates them for status dots and 1px borders on OLED, not
 * paragraph-sized copy.
 */

:root {
  color-scheme: dark light;

  /* Brand palette — SHA-814 asset pack. The source of truth for the identity;
     also mirrored in the cian-brand skill. Rust is deliberately NOT the alert
     crimson; see the note above. */
  --brand-rust: #c94436; /* primary strand, wordmark accent, the mark */
  --brand-rust-deep: #a8301f; /* the ring */
  --brand-aqua: #4fa89c; /* the mark's vias and routed stem; text selection */
  --brand-base: #0a1418; /* ground — the mark's tile, == --bg-subtle */

  /* CIAN "Evening" — page/surface-base/surface-raised, border-subtle/strong,
     text-primary/secondary, verbatim from the source doc. */
  --bg: #060e11;
  --bg-subtle: #0a1418;
  --bg-raised: #0f1d22;
  --border: #1a2f36;
  --border-strong: #26454e;
  --text: #ccd8db;
  --text-muted: #8ba0a6;

  /* Interactive accent = brand Rust, lightened to clear the 4.5:1 AA floor as
     link-sized text on the dark ground (canonical #c94436 is ~3.9:1 there —
     right for the mark and graphics, short for small text). Warm/orange,
     which also keeps it clearly apart from the pink-red BLOCKED danger. */
  --accent: #d96a52;
  --accent-text: #04090b;
  --accent-subtle: #241310;

  /* State colours, brightened from the doc's dot/border values for use as
     text and small UI at normal marketing-site sizes. */
  --danger: #d6607a; /* BLOCKED */
  --danger-subtle: #2a161a;
  --success: #3cc2a8; /* HEALTHY */
  --success-subtle: #0d211c;
  --warn: #c9871f; /* AWAITING */
  --warn-subtle: #241c08;

  --radius: 6px;
  --wrap: 68rem;
  --measure: 42rem;
}

@media (prefers-color-scheme: light) {
  :root {
    /* Not in either source doc — the product has no light mode. Surfaces are
       derived from the same cool-teal hue family (several values reuse the UI
       Guidelines' dimmer "Night Watch" tier, which already reads well on
       white); the brand tokens themselves do not change per scheme. */
    --bg: #f6f9fa;
    --bg-subtle: #eef3f4;
    --bg-raised: #ffffff;
    --border: #d3dde0;
    --border-strong: #a9bcc1;
    --text: #10191c;
    --text-muted: #4d6167;

    /* Rust Deep (a brand token, the ring colour) as the accent here: canonical
       Rust is ~4.35:1 on this near-white ground, just under AA for text, while
       Rust Deep clears 6:1. */
    --accent: #a8301f;
    --accent-text: #ffffff;
    --accent-subtle: #f7e6e2;
    --danger: #8c2b3c; /* BLOCKED, Night Watch tier */
    --danger-subtle: #fbe9ec;
    --success: #0a6c5c; /* HEALTHY, Night Watch tier */
    --success-subtle: #e3f3ef;
    --warn: #8f5c11; /* AWAITING, darkened for AA on white */
    --warn-subtle: #fbf1e0;
  }
}

/*
 * Fira Sans (Display/UI) and JetBrains Mono (Machine) are the product's
 * typefaces, self-hosted rather than loaded from a font CDN — this Worker's
 * CSP sets font-src 'self', and a marketing site pulling from Google Fonts
 * would be one more third party in the request path for no real gain. Latin
 * subset only, OFL-1.1 licensed; see src/assets/fonts/LICENSE-*.txt.
 */
@font-face {
  font-family: "Fira Sans";
  src: url("/assets/fonts/fira-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fira Sans";
  src: url("/assets/fonts/fira-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fira Sans";
  src: url("/assets/fonts/fira-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Fira Sans", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

main.wrap {
  flex: 1 0 auto;
  padding-block: 2.5rem 4rem;
}

/* ---------------------------------------------------------------- typography */

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 600; /* Fira Sans Display, per the source doc's type table */
  letter-spacing: -0.015em;
  margin: 0 0 0.6em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem);
}
h2 {
  font-size: clamp(1.4rem, 1.15rem + 1vw, 1.85rem);
  margin-top: 2.5rem;
}
h3 {
  font-size: 1.125rem;
  margin-top: 1.75rem;
}

p,
ul,
ol,
dl {
  margin: 0 0 1.1rem;
}

p,
li {
  max-width: var(--measure);
  text-wrap: pretty;
}

ul,
ol {
  padding-left: 1.35rem;
}

li + li {
  margin-top: 0.4rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

strong {
  font-weight: 600;
}

/* Aqua is a brand token (the mark's vias and routed stem). Text selection is
   a genuinely non-state surface, so it can carry brand colour without
   colliding with the reserved BUILDING meaning aqua has inside the product. */
::selection {
  background: var(--brand-aqua);
  color: #04090b;
}

/* JetBrains Mono is the product's "Machine" role — reserved for exactly the
   kind of content it marks in the app itself: literal, machine-produced
   text, not styled prose. */
code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono",
    Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}

.lede {
  font-size: clamp(1.05rem, 1rem + 0.35vw, 1.2rem);
  color: var(--text-muted);
  max-width: var(--measure);
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------- a11y */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.7rem 1.1rem;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

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

@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;
  }
}

/* ----------------------------------------------------------------- header */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  /* The real mark (cian-mark.svg) carries its own brand colours — rust strands,
     rust-deep ring, aqua vias — so this only sizes it. Slightly larger than the
     wordmark cap-height so the knotwork reads at header size. */
  width: 1.7em;
  height: 1.7em;
  display: block;
  flex-shrink: 0;
}

.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.35rem;
}

.site-nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  padding-block: 0.2rem;
  border-bottom: 2px solid transparent;
}

.site-nav-links a:hover {
  color: var(--text);
}

.site-nav-links a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ----------------------------------------------------------------- footer */

.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding-block: 2.5rem;
  font-size: 0.925rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 3rem;
  justify-content: space-between;
}

.footer-brand {
  max-width: 22rem;
}

.footer-name {
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.footer-note {
  color: var(--text-muted);
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3rem;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.footer-col h2 {
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin: 0 0 0.25rem;
  font-weight: 600;
}

.footer-col a {
  color: var(--text);
  text-decoration: none;
}

.footer-col a:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------- components */

.hero {
  padding-block: 1.5rem 1rem;
}

.eyebrow {
  display: inline-block;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.notice {
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  padding: 1rem 1.15rem;
  margin-block: 1.75rem;
}

.notice > :last-child {
  margin-bottom: 0;
}

.notice h2,
.notice h3 {
  margin-top: 0;
  font-size: 1rem;
}

.notice-status {
  border-left-color: var(--accent);
  background: var(--accent-subtle);
}

.notice-warn {
  border-left-color: var(--warn);
  background: var(--warn-subtle);
}

.notice-draft {
  /* Amber, not red: a draft awaiting legal review is CIAN's AWAITING state
     ("a human is needed"), not BLOCKED ("hard failure"). */
  border-left-color: var(--warn);
  background: var(--warn-subtle);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr));
  gap: 1rem;
  margin-block: 1.5rem;
  padding: 0;
  list-style: none;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 1.15rem 1.25rem;
  margin: 0;
}

.card h3 {
  margin-top: 0;
  font-size: 1.05rem;
}

.card p {
  margin-bottom: 0;
  color: var(--text-muted);
  max-width: none;
}

.card li {
  max-width: none;
}

.status-list {
  list-style: none;
  padding: 0;
  margin-block: 1.25rem;
  display: grid;
  gap: 0.6rem;
}

.status-list li {
  display: grid;
  grid-template-columns: minmax(7.5rem, max-content) 1fr;
  gap: 0.25rem 1rem;
  align-items: baseline;
  max-width: none;
  margin: 0;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 34rem) {
  .status-list li {
    grid-template-columns: 1fr;
  }
}

.tag {
  display: inline-block;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

/* Built/in progress/not started reuses CIAN's own state vocabulary:
   HEALTHY (done), AWAITING (not finished — needs more work before it counts),
   IDLE (nothing running yet) — kept as three visibly distinct hues rather
   than a literal 1:1 state-machine mapping, since that is what the status
   list in src/pages/features.html actually needs to communicate at a glance. */
.tag-built {
  color: var(--success);
  background: var(--success-subtle);
}

.tag-progress {
  color: var(--warn);
  background: var(--warn-subtle);
}

.tag-planned {
  color: var(--text-muted);
  background: var(--bg-subtle);
}

.pipeline {
  margin-block: 1.5rem;
  padding: 0;
  list-style: none;
  counter-reset: phase;
  border-left: 2px solid var(--border);
}

.pipeline li {
  position: relative;
  padding: 0 0 1.15rem 1.5rem;
  max-width: var(--measure);
  margin: 0;
}

.pipeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.6em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.pipeline li.is-gate::before {
  /* BLOCKED crimson: a hard gate is the one point in the pipeline that
     actually halts on failure, same as the product's own gate semantics. */
  background: var(--danger);
  width: 12px;
  height: 12px;
  left: -7px;
}

.pipeline strong {
  display: block;
}

.legal-meta {
  color: var(--text-muted);
  font-size: 0.925rem;
  margin-bottom: 2rem;
}

.placeholder {
  background: var(--warn-subtle);
  color: var(--warn);
  border: 1px dashed currentColor;
  border-radius: 4px;
  padding: 0.05em 0.4em;
  font-weight: 600;
  font-size: 0.925em;
}

/* ------------------------------------------------------------------- form */

.form {
  max-width: var(--measure);
  margin-top: 1.75rem;
}

.field {
  margin-bottom: 1.35rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.field .hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 0.4rem;
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}

textarea {
  min-height: 9rem;
  resize: vertical;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0.35rem 0 0;
  font-weight: 500;
}

.field-error:empty {
  display: none;
}

/*
 * "No colour-filled buttons. A primary action is a brighter surface and a
 * stronger border" — CIAN UI Guidelines, Principle 7. Colour is reserved for
 * state elsewhere on this page (tags, form status, the draft banner); buttons
 * stay neutral so they never compete with those signals.
 */
.button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.65rem 1.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.button:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
  border-color: var(--border-strong);
  background: var(--bg-raised);
}

.button-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.button-secondary:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: transparent;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

.form-status {
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-block: 1.5rem;
  border: 1px solid;
}

.form-status:empty {
  display: none;
  padding: 0;
  border: 0;
  margin: 0;
}

.form-status > :last-child {
  margin-bottom: 0;
}

.form-status h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.form-status-error {
  border-color: var(--danger);
  background: var(--danger-subtle);
  color: var(--danger);
}

.form-status-success {
  border-color: var(--success);
  background: var(--success-subtle);
  color: var(--success);
}

.form-status a {
  color: inherit;
}

.turnstile-holder {
  margin-bottom: 1.25rem;
  min-height: 65px;
}

.no-js-warning {
  border: 1px solid var(--warn);
  background: var(--warn-subtle);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-block: 1.5rem;
}

.no-js-warning > :last-child {
  margin-bottom: 0;
}
