/* ============================================================================
   Cornerstone Manufacturing - shared brand layer
   Design tokens for every surface (site pages, part viewer, experience,
   quote portal, order portal, blog).

   Load order on every page:
     <link rel="stylesheet" href="/assets/css/core.css">

   Fonts are SELF-HOSTED woff2 (latin subset) in ../fonts/. Never hotlink a
   font CDN: this build has a hard no-CDN-at-runtime rule.

   PALETTE (2026-07-28) - retokened to Cornerstone's real brand:
     white #FFFFFF ground, warm neutral panel #EDE8E0, rust accent #C8502D,
     ink #1A1D21, body #333333.

   Contrast, measured against the ground each colour actually sits on
   (deliberate, do not "fix" without re-measuring):
     rust  #C8502D on white ........ 4.52:1  AA normal text, and AA for white
                                             text ON it (4.64:1) - buttons OK
     rust-ink #A93F20 on white ..... 6.14:1  the link/text rust
     rust-ink #A93F20 on panel ..... 5.04:1
     ink   #1A1D21 on white ....... 16.9:1
     body  #333333 on white ....... 12.6:1
     muted #6B6560 on white ........ 5.74:1  (4.71:1 on the warm panel)
     rust  #C8502D on ink .......... 3.74:1  large text / graphics only
     salmon #F5A98B on ink ......... 4.88:1  the on-dark link colour
   ========================================================================== */

/* ---- Self-hosted fonts --------------------------------------------------- */
/* Archivo - variable, headings and body. */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 100%;
  font-display: swap;
  src: url('../fonts/archivo-latin-var.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono - eyebrows, specs, dimensions, tolerances, part numbers. */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibmplexmono-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/ibmplexmono-latin-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Design tokens ------------------------------------------------------- */
:root {
  /* Brand palette */
  --cs-primary: #C8502D;         /* rust - the accent */
  --cs-primary-hi: #D9603C;      /* rust, hover/active lift */
  --cs-primary-ink: #A93F20;     /* deep rust - AA text + links on white */
  --cs-primary-soft: #FBEDE8;    /* rust tint - hover washes, callout grounds */
  --cs-primary-on-dark: #F5A98B; /* salmon - links on the ink ground (4.88:1) */
  --cs-secondary: #1A1D21;       /* ink - dark surfaces */
  --cs-secondary-hi: #2A2E33;    /* ink, hover */
  --cs-dark: #1A1D21;            /* default heading ink */
  --cs-body: #333333;            /* body copy */
  --cs-info: #6B6560;            /* warm muted text */
  --cs-light: #EDE8E0;           /* warm neutral panel */
  --cs-panel: #EDE8E0;           /* alias, reads better in new code */
  --cs-line: #DCD5CA;            /* hairline borders on white/panel */
  --cs-accent-1: #8C4526;        /* deep rust-brown */
  --cs-accent-2: #9A8B7A;        /* warm stone */
  --cs-accent-3: #D8CEC0;        /* sand */
  --cs-success: #2F7D4F;
  --cs-warning: #E8B04B;         /* amber FILL - pair with --cs-warning-ink */
  --cs-warning-ink: #4A3200;
  --cs-danger: #B3261E;
  --cs-white: #FFFFFF;
  --cs-black: #000000;

  /* Warm neutral ramp (replaces the old cool greys, same token names) */
  --cs-gray-100: #FAF8F5;
  --cs-gray-200: #F0EBE3;
  --cs-gray-300: #DCD5CA;
  --cs-gray-400: #C9C0B2;
  --cs-gray-600: #6B6560;
  --cs-gray-700: #4A4540;
  --cs-gray-800: #2E2B28;
  --cs-gray-900: #1A1D21;

  /* Type */
  --cs-font-display: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cs-font-body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cs-font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Shape + elevation */
  --cs-radius: 10px;
  --cs-radius-sm: 6px;
  --cs-shadow-1: 0 1px 3px rgba(26, 29, 33, 0.07), 0 1px 2px rgba(26, 29, 33, 0.05);
  --cs-shadow-2: 0 8px 24px rgba(26, 29, 33, 0.11);
  --cs-focus: rgba(200, 80, 45, 0.40);

  /* Spacing scale */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

html, body {
  max-width: 100%;
  overflow-x: hidden; /* iPhone-width safety: no horizontal scroll, ever */
}

body {
  margin: 0;
  font-family: var(--cs-font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--cs-body);
  background: var(--cs-white);
  -webkit-font-smoothing: antialiased;
}

img, video, canvas, model-viewer { max-width: 100%; height: auto; }

/* The UA rule for [hidden] is display:none at the LOWEST specificity, so any
   component class that sets display:flex or display:grid silently defeats it
   and a "hidden" panel stays on screen. Several components here do exactly
   that, and every tab/panel/filter on this site relies on the attribute.
   Do not remove. */
[hidden] { display: none !important; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--cs-font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--cs-dark);
  margin: 0 0 0.5em;
}
/* Mobile-first sizes; desktop scale at >=768px */
h1 { font-size: 34px; line-height: 1.08; }
h2 { font-size: 27px; line-height: 1.15; }
h3 { font-size: 22px; line-height: 1.2; }
h4 { font-size: 19px; line-height: 1.3; }
h5 { font-size: 17px; line-height: 1.3; }
h6 { font-size: 15px; line-height: 1.3; font-weight: 600; }
@media (min-width: 768px) {
  h1 { font-size: 56px; line-height: 1.04; }
  h2 { font-size: 34px; line-height: 1.15; }
  h3 { font-size: 25px; line-height: 1.2; }
  h4 { font-size: 21px; line-height: 1.3; }
  h5 { font-size: 18px; line-height: 1.3; }
}

p { margin: 0 0 1em; }
.lead { font-size: 19px; line-height: 1.65; color: var(--cs-gray-700); }
.fine-print { font-size: 14px; line-height: 1.55; color: var(--cs-info); }

/* Mono utility - eyebrows, spec values, data. The brand's second voice. */
.mono { font-family: var(--cs-font-mono); font-variant-ligatures: none; }
.eyebrow {
  font-family: var(--cs-font-mono);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cs-primary-ink);
  margin: 0 0 var(--sp-3);
}
.on-dark .eyebrow { color: var(--cs-primary-on-dark); }

a { color: var(--cs-primary-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--cs-secondary); }

/* Dark (ink) sections - flip ink colours */
.on-dark, .on-dark h1, .on-dark h2, .on-dark h3, .on-dark h4, .on-dark h5, .on-dark h6 { color: var(--cs-white); }
.on-dark { background: var(--cs-secondary); color: #F2EFEA; }
.on-dark a { color: var(--cs-primary-on-dark); }
.on-dark a:hover { color: var(--cs-white); }
.on-dark .fine-print { color: var(--cs-accent-3); }

/* Focus - visible, consistent, never removed */
:focus-visible {
  outline: 3px solid var(--cs-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Screen-reader-only helper */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Layout helpers ------------------------------------------------------ */
.container { width: 100%; max-width: 1160px; margin-inline: auto; padding-inline: var(--sp-4); }
@media (min-width: 768px) { .container { padding-inline: var(--sp-5); } }
.section { padding-block: var(--sp-6); }
@media (min-width: 768px) { .section { padding-block: var(--sp-7); } }
.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 48px;                 /* thumb-sized touch target */
  padding: 12px 24px;
  border: 1.5px solid transparent;
  border-radius: var(--cs-radius-sm);
  font-family: var(--cs-font-display);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0.1px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* Primary - rust fill, white ink (4.64:1, AA) */
.btn--primary { background: var(--cs-primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--cs-primary-hi); box-shadow: var(--cs-shadow-1); }
.btn--primary:active:not(:disabled) { background: var(--cs-primary-ink); color: var(--cs-white); }

/* Secondary - ink fill, white ink (16.9:1) */
.btn--secondary { background: var(--cs-secondary); color: var(--cs-white); }
.btn--secondary:hover:not(:disabled) { background: var(--cs-secondary-hi); box-shadow: var(--cs-shadow-1); }

/* Ghost - outline, inherits context */
.btn--ghost { background: transparent; color: var(--cs-secondary); border-color: var(--cs-gray-400); }
.btn--ghost:hover:not(:disabled) { background: var(--cs-primary-soft); border-color: var(--cs-primary); color: var(--cs-primary-ink); }
.on-dark .btn--ghost { color: var(--cs-white); border-color: rgba(255,255,255,.45); }
.on-dark .btn--ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); border-color: #fff; color: #fff; }

.btn--sm { min-height: 38px; padding: 7px 16px; font-size: 14px; }

/* Forced colors (Windows High Contrast): filled buttons lose their background
   and a transparent border would leave no visible boundary. */
@media (forced-colors: active) {
  .btn { border-color: ButtonBorder; }
  .btn:disabled, .btn[aria-disabled="true"] { border-color: GrayText; color: GrayText; }
}
.btn--block { display: flex; width: 100%; }

/* Busy state (the form helper toggles this while posting) */
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 2.5px solid rgba(26, 29, 33, 0.25); border-top-color: var(--cs-secondary);
  border-radius: 50%; animation: cs-spin .7s linear infinite;
}
.btn--primary.is-busy::after, .btn--secondary.is-busy::after { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
@keyframes cs-spin { to { transform: rotate(360deg); } }

/* ---- Cards --------------------------------------------------------------- */
.card {
  background: var(--cs-white);
  border: 1px solid var(--cs-line);
  border-radius: var(--cs-radius);
  box-shadow: var(--cs-shadow-1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
a.card { text-decoration: none; color: inherit; transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
a.card:hover { box-shadow: var(--cs-shadow-2); border-color: var(--cs-primary); transform: translateY(-2px); }
.card__media { aspect-ratio: 16 / 10; object-fit: cover; width: 100%; background: var(--cs-gray-200); }
.card__body { padding: var(--sp-4) var(--sp-4) var(--sp-5); flex: 1; }
.card__title { font-family: var(--cs-font-display); font-weight: 700; font-size: 20px; margin: 0 0 var(--sp-2); color: var(--cs-dark); }
.card__text { font-size: 15px; color: var(--cs-info); margin: 0; }
.card__footer { padding: 0 var(--sp-4) var(--sp-4); }

/* Small label chip */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-family: var(--cs-font-mono); font-weight: 600; font-size: 12px; line-height: 1.5;
  letter-spacing: .04em;
  background: var(--cs-primary-soft); color: var(--cs-primary-ink);
}
.badge--ink { background: var(--cs-secondary); color: var(--cs-white); }
.badge--sand { background: var(--cs-accent-3); color: var(--cs-secondary); }
.badge--petrol { background: var(--cs-secondary); color: var(--cs-white); } /* legacy alias */

/* ---- Spec table ---------------------------------------------------------- */
/* Wide tables scroll inside their own wrapper - the page never scrolls sideways */
.spec-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--cs-line); border-radius: var(--cs-radius); }
.spec-table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 320px; }
.spec-table caption { text-align: left; font-family: var(--cs-font-display); font-weight: 700; font-size: 18px; padding: var(--sp-3) var(--sp-4); color: var(--cs-dark); }
.spec-table th, .spec-table td { padding: 10px var(--sp-4); text-align: left; border-top: 1px solid var(--cs-line); }
.spec-table thead th {
  border-top: 0; background: var(--cs-secondary); color: var(--cs-white);
  font-family: var(--cs-font-mono); font-weight: 600; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.spec-table tbody th { font-weight: 600; color: var(--cs-gray-800); white-space: nowrap; width: 1%; padding-right: var(--sp-6); background: var(--cs-gray-100); }
.spec-table tbody tr:nth-child(even) td { background: var(--cs-gray-100); }
.spec-table td { font-family: var(--cs-font-mono); font-size: 14px; }
.spec-table td.txt { font-family: var(--cs-font-body); font-size: 15px; }
.spec-table td .unit { color: var(--cs-info); font-size: 13px; }

/* ---- Forms --------------------------------------------------------------- */
.field { margin-bottom: var(--sp-4); }
.field label {
  display: block; margin-bottom: var(--sp-1);
  font-family: var(--cs-font-display); font-weight: 600; font-size: 15px; color: var(--cs-dark);
}
.field label .req { color: var(--cs-danger); }
.field__hint { display: block; font-size: 13px; color: var(--cs-info); margin-top: var(--sp-1); }

.field input, .field select, .field textarea {
  display: block; width: 100%;
  padding: 12px 14px;
  font: inherit; font-size: 16px;   /* >=16px prevents iOS zoom-on-focus */
  color: var(--cs-dark);
  background: var(--cs-white);
  border: 1.5px solid var(--cs-gray-400);
  border-radius: var(--cs-radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--cs-primary);
  box-shadow: 0 0 0 3px var(--cs-focus);
}

/* Inline validation (the form helper toggles these) */
.field.field--invalid input, .field.field--invalid select, .field.field--invalid textarea {
  border-color: var(--cs-danger);
}
.field.field--invalid input:focus, .field.field--invalid textarea:focus {
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.3);
}
.field__error { display: block; margin-top: var(--sp-1); font-size: 14px; color: var(--cs-danger); }
.field.field--valid input, .field.field--valid textarea { border-color: var(--cs-success); }

/* Honeypot - hidden from humans, present for bots. NEVER display:none
   (some bots skip display:none fields); off-screen + aria-hidden instead. */
.hp-wrap {
  position: absolute !important; left: -9999px !important; top: auto !important;
  width: 1px; height: 1px; overflow: hidden;
}

/* ---- Toasts (aria-live) --------------------------------------------------- */
.toast-region {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: center;
  z-index: 1000; width: min(92vw, 480px); pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: var(--cs-secondary); color: var(--cs-white);
  border-left: 4px solid var(--cs-primary);
  border-radius: var(--cs-radius-sm);
  box-shadow: var(--cs-shadow-2);
  font-size: 15px; line-height: 1.45;
  animation: cs-toast-in .25s ease;
}
.toast--success { border-left-color: var(--cs-success); }
.toast--error { border-left-color: var(--cs-danger); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .3s ease, transform .3s ease; }
@keyframes cs-toast-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.is-leaving, a.card:hover { animation: none; transition: none; transform: none; }
}

/* ---- Header / footer scaffolding (legacy demo surfaces) ------------------- */
.site-header {
  background: var(--cs-secondary);
  padding: var(--sp-3) 0;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.site-header__logo img { display: block; height: 34px; width: auto; }
.site-header nav { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.site-header nav a {
  color: var(--cs-light); text-decoration: none;
  font-family: var(--cs-font-display); font-weight: 600; font-size: 15px;
}
.site-header nav a:hover, .site-header nav a[aria-current="page"] { color: var(--cs-primary-on-dark); }

.site-footer { background: var(--cs-secondary); color: var(--cs-accent-3); padding: var(--sp-5) 0; font-size: 14px; }
.site-footer a { color: var(--cs-light); }
