/* ==========================================================================
   CAFlash Tuning - static site
   Type:  IBM Plex Sans Condensed (display) / IBM Plex Sans (body) / IBM Plex Mono (data)
   Colour: workshop-manual greys + restrained BMW M tricolour
   ========================================================================== */

:root {
  --ink:        #10151a;
  --graphite:   #2b333b;
  --slate:      #6b7680;
  --line:       #d3d8dc;
  --line-soft:  #e4e8ea;
  --paper:      #eef0f2;
  --surface:    #ffffff;

  --m-blue:     #0653a0;
  --m-cyan:     #7db6e8;
  --m-red:      #d2202a;

  --display: "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  --body:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  --gutter: clamp(1.25rem, 4vw, 4rem);
  --maxw: 1180px;
  --r: 2px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--m-blue);
  outline-offset: 3px;
}

.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* --- structural device: the M tricolour rule ----------------------------- */
.rule {
  display: flex;
  height: 3px;
  width: 64px;
  margin-bottom: 1rem;
}
.rule i { flex: 1; }
.rule i:nth-child(1) { background: var(--m-cyan); }
.rule i:nth-child(2) { background: var(--m-blue); }
.rule i:nth-child(3) { background: var(--m-red); }

.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 .35rem;
}

/* --- header -------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(238, 240, 242, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  gap: 1rem;
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.28rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.brand .stripes {
  display: flex;
  height: 15px;
  width: 9px;
}
.brand .stripes i { flex: 1; }
.brand .stripes i:nth-child(1) { background: var(--m-cyan); }
.brand .stripes i:nth-child(2) { background: var(--m-blue); }
.brand .stripes i:nth-child(3) { background: var(--m-red); }

.nav {
  display: flex;
  gap: 1.6rem;
  align-items: center;
}
.nav a {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--graphite);
  padding: .3rem 0;
  border-bottom: 2px solid transparent;
  transition: border-color .18s, color .18s;
}
.nav a:hover, .nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--m-blue);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .45rem .6rem;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--ink);
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: .5rem var(--gutter) 1rem;
    display: none;
  }
  .nav[data-open="true"] { display: flex; }
  .nav a {
    padding: .85rem 0;
    border-bottom: 1px solid var(--line-soft);
  }
}

/* --- hero: the calibration table ----------------------------------------- */
.hero {
  position: relative;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface);
}
.hero .wrap {
  position: relative;
  padding-block: clamp(3.5rem, 9vw, 6.5rem);
  /* single column since the photograph was dropped; the mesh backdrop and the
     max-width on .lede keep the measure readable on a wide screen */
  max-width: var(--maxw);
}

.hero h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 7vw, 4.5rem);
  line-height: .95;
  letter-spacing: -.02em;
  text-transform: uppercase;
  margin: .4rem 0 1rem;
  text-wrap: balance;
}
.hero h1 em {
  font-style: normal;
  display: block;
  color: var(--m-blue);
}
.hero p.lede {
  font-size: 1.06rem;
  color: var(--graphite);
  max-width: 46ch;
  margin: 0 0 1.8rem;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

/* faint wireframe backdrop, bleeding off the right edge */
.hero-mesh {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--m-blue);
  opacity: .13;
  pointer-events: none;
  z-index: 0;
}
.hero .wrap { z-index: 1; }
@media (max-width: 900px) { .hero-mesh { opacity: .09; } }

/* text beside a visual */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .85fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  margin-bottom: 2.5rem;
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.split .section-head { margin-bottom: 0; }

/* decorative 3D calibration surface */
.surface {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  padding: .9rem;
  box-shadow: 0 1px 0 var(--line-soft), 0 18px 40px -28px rgba(16, 21, 26, .5);
}
.surface-head {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: .4rem;
}
.surface-head b { color: var(--ink); font-weight: 600; }
.surface svg { display: block; width: 100%; height: auto; }
/* fades in when scrolled to; see app.js */
.surface svg { opacity: 0; transition: opacity .8s ease; }
.surface svg[data-shown="true"] { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .surface svg { opacity: 1; transition: none; }
}

/* --- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: .8rem 1.35rem;
  border-radius: var(--r);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
}
.btn:hover { background: var(--m-blue); border-color: var(--m-blue); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* --- sections ------------------------------------------------------------ */
section { padding-block: clamp(3rem, 7vw, 5.5rem); }
section + section { border-top: 1px solid var(--line); }

h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.9rem, 4vw, 2.9rem);
  line-height: 1.02;
  letter-spacing: -.01em;
  text-transform: uppercase;
  margin: 0 0 1rem;
}
h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: .01em;
  margin: 0 0 .4rem;
}

.section-head { max-width: 62ch; margin-bottom: 2.5rem; }
.section-head p { color: var(--graphite); margin: 0; }

/* capability cards */
.caps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  /* surface, not --line: a row that doesn't divide evenly by the column count
     leaves empty cells, and a --line background turns those into grey blocks.
     The dividing lines come from each card's outset shadow instead, which only
     exists where there is actually a card. */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.cap {
  background: var(--surface);
  padding: 1.6rem 1.4rem;
  /* bleeds into the 1px gap on every side; neighbours overlap into one line */
  box-shadow: 0 0 0 1px var(--line);
}
.cap .n {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .12em;
  color: var(--m-blue);
  display: block;
  margin-bottom: .8rem;
}
.cap p { margin: 0; color: var(--graphite); font-size: .95rem; }

/* app cards - same family as .product, but link-led rather than price-led */
.apps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.1rem;
}
.app {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.app h3 { margin: 0; }
/* push the button to the bottom so cards of different text lengths line up */
.app p { margin: 0 0 .5rem; color: var(--graphite); font-size: .95rem; flex: 1; }
.app .btn { align-self: start; }

/* a closing aside under a section's cards */
.section-note {
  margin: 1.6rem 0 0;
  color: var(--graphite);
  font-size: .95rem;
}
.section-note a { color: var(--m-blue); }

/* shop subsections */
.shop-group + .shop-group { margin-top: clamp(2rem, 4vw, 3rem); }
.shop-group-head {
  max-width: 62ch;
  margin-bottom: 1.2rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--line);
}
.shop-group-head h3 { margin: 0; }
.shop-group-head p {
  margin: .3rem 0 0;
  color: var(--slate);
  font-size: .92rem;
}

/* --- products ------------------------------------------------------------ */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 1.1rem;
}
.product {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: border-color .18s, transform .18s;
}
.product:hover { border-color: var(--m-blue); transform: translateY(-2px); }
.product .tag,
.app .tag {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--slate);
}
.product h4 {
  /* h3-equivalent styling: the shop group heading is the h3 now */
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: .01em;
  margin: 0;
}
.product .desc {
  font-size: .92rem;
  color: var(--graphite);
  margin: 0;
  flex: 1;
}
.product .price {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -.02em;
}
.product .price small {
  font-size: .7rem;
  color: var(--slate);
  letter-spacing: .1em;
  margin-left: .3rem;
}
.product .btn { justify-content: center; }

/* --- FAQ ----------------------------------------------------------------- */
.faq-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 2.5rem;
}
.faq-nav a {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: .5rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .18s, color .18s;
}
.faq-nav a:hover { border-color: var(--m-blue); color: var(--m-blue); }

.faq-group { margin-bottom: 3rem; scroll-margin-top: 80px; }
.faq-group > h2 { margin-bottom: 1.5rem; }

details.qa {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: .6rem;
}
details.qa + details.qa { margin-top: -1px; }
details.qa summary {
  cursor: pointer;
  padding: 1.05rem 1.3rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.08rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
details.qa summary::-webkit-details-marker { display: none; }
details.qa summary::after {
  content: "+";
  font-family: var(--mono);
  color: var(--m-blue);
  font-size: 1.2rem;
  flex: none;
}
details.qa[open] summary::after { content: "–"; }
details.qa .body {
  padding: 0 1.3rem 1.25rem;
  color: var(--graphite);
  font-size: .96rem;
}
details.qa .body p:first-child { margin-top: 0; }
details.qa .body p:last-child { margin-bottom: 0; }
details.qa .body code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--paper);
  padding: .12em .35em;
  border-radius: 2px;
}
details.qa .body ul { padding-left: 1.1rem; }
details.qa .body li { margin-bottom: .35rem; }

/* --- contact ------------------------------------------------------------- */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}
@media (max-width: 820px) { .contact-grid { grid-template-columns: 1fr; } }

form.contact { display: grid; gap: .9rem; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
}
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

label {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate);
  display: block;
  margin-bottom: .35rem;
}
input, textarea, select {
  width: 100%;
  font-family: var(--body);
  font-size: .98rem;
  padding: .75rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
}
input:focus, textarea:focus { border-color: var(--m-blue); outline: none; }
textarea { min-height: 130px; resize: vertical; }

.form-status {
  font-family: var(--mono);
  font-size: .78rem;
  padding: .6rem 0;
  display: none;
}
.form-status[data-state="ok"]   { display: block; color: var(--m-blue); }
.form-status[data-state="err"]  { display: block; color: var(--m-red); }

/* --- footer -------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-block: 2.5rem;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .06em;
  color: var(--slate);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* --- prose (policy pages) ------------------------------------------------ */
.prose { max-width: 68ch; }
.prose h2 { font-size: 1.6rem; margin-top: 2.5rem; }
.prose p, .prose li { color: var(--graphite); }
.prose h3 { margin: 2.2rem 0 .6rem; }
.prose h4 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 1.4rem 0 .4rem;
}
.prose p { margin: 0 0 1rem; }
.prose ul { margin: 0 0 1rem; padding-left: 1.1rem; }
.prose li { margin-bottom: .35rem; }

/* custom-amount product - reads as a different kind of thing to a fixed price */
.product-custom {
  border-style: dashed;
  border-color: var(--slate);
}
.product-custom .price {
  font-family: var(--display);
  font-size: 1.3rem;
  letter-spacing: .01em;
}
.product-custom .price small {
  font-family: var(--mono);
  display: block;
  margin: .15rem 0 0;
}

/* quiet secondary link under a product CTA */
.product-link {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .06em;
  color: var(--slate);
  text-align: center;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  align-self: center;
  transition: color .18s, border-color .18s;
}
.product-link:hover { color: var(--m-blue); border-bottom-color: var(--m-blue); }

/* not sold off the shelf - available on request only */
.product-enquiry { background: transparent; }
.product-enquiry h3, .product-enquiry .price { color: var(--slate); }
.badge {
  font-weight: 500;
  color: var(--m-red);
  letter-spacing: .1em;
  margin-left: .35rem;
}

/* Google Play badge - icon plus the two-line lockup those badges use */
.play-badge {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  align-self: start;
  padding: .45rem .95rem .45rem .8rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transition: background .18s, border-color .18s;
}
.play-badge:hover { background: var(--m-blue); border-color: var(--m-blue); }
.play-badge .pb-icon { width: 22px; height: 22px; flex: none; }
.play-badge .pb-text { display: flex; flex-direction: column; line-height: 1.15; }
.play-badge .pb-top {
  font-family: var(--mono);
  font-size: .55rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .8;
}
.play-badge .pb-main {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: .01em;
}

/* "Instant" - fulfilled by the order API as soon as payment clears */
.badge-instant { color: var(--m-blue); }

/* --- checkout dialog ------------------------------------------------------ */
dialog.checkout {
  width: min(34rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 70px -30px rgba(16, 21, 26, .55);
}
dialog.checkout::backdrop {
  background: rgba(16, 21, 26, .45);
  backdrop-filter: blur(2px);
}

.checkout-form {
  display: grid;
  gap: .9rem;
  padding: clamp(1.25rem, 4vw, 1.9rem);
  /* the tall products run past the viewport on a phone */
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}
.checkout-form [data-fields] { display: grid; gap: .9rem; }
.checkout-form textarea { min-height: 74px; }

.checkout-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: .9rem;
}
.checkout-head h3 { margin: 0; }
.checkout-head .eyebrow { margin: 0 0 .3rem; }

.checkout-close {
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 .2rem;
  color: var(--slate);
}
.checkout-close:hover { color: var(--m-red); }

.checkout-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--line);
  padding-top: .9rem;
}
.checkout-total span {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate);
}
.checkout-total b {
  font-family: var(--display);
  font-size: 1.5rem;
  letter-spacing: -.01em;
}

.checkout-note {
  margin: 0;
  font-size: .8rem;
  color: var(--slate);
  text-align: center;
}

small.hint {
  display: block;
  margin-top: .35rem;
  font-size: .78rem;
  line-height: 1.4;
  color: var(--slate);
}

.order-ref {
  font-family: var(--mono);
  font-size: .82rem;
  word-break: break-all;
  color: var(--slate);
  border-left: 2px solid var(--m-blue);
  padding-left: .8rem;
}

/* --- currency picker ------------------------------------------------------ */
.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;
}

.currency-picker select {
  width: auto;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .08em;
  padding: .35rem 1.6rem .35rem .5rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--graphite);
  cursor: pointer;
  /* the native arrow sits too far out on a control this small */
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--slate) 50%),
                    linear-gradient(135deg, var(--slate) 50%, transparent 50%);
  background-position: right .7rem center, right .45rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.currency-picker select:hover { border-color: var(--m-blue); color: var(--ink); }

@media (max-width: 760px) {
  .currency-picker { padding: .85rem 0 .2rem; }
}

/* --- policy pages: date line and tables ----------------------------------- */
.policy-date {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--slate);
  margin: -.5rem 0 1.8rem;
}

.policy-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.4rem;
  font-size: .9rem;
  /* narrow screens: let it scroll rather than squeeze the page sideways */
  display: block;
  overflow-x: auto;
}
.policy-table th, .policy-table td {
  border: 1px solid var(--line);
  padding: .6rem .7rem;
  text-align: left;
  vertical-align: top;
  color: var(--graphite);
}
.policy-table th {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--slate);
  background: var(--line-soft);
  white-space: nowrap;
}
.prose code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--line-soft);
  padding: .1rem .3rem;
  border-radius: var(--r);
}
