/* SWMS Link screens. Tokens and rules come from DESIGN.md (main checkout). Every font size is in rem, so the
   phone's text-size setting and browser zoom apply. Flat: no shadows, no gradients. No hi-vis yellow here:
   it's for marketing only. Error and success states are provisional until the screen mockups land (ruling P1). */

@font-face { font-family: "Overpass"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/overpass-400.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 800; font-style: normal; font-display: swap; src: url("/fonts/overpass-800.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 900; font-style: normal; font-display: swap; src: url("/fonts/overpass-900.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/atkinson-next-400.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/atkinson-next-500.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/atkinson-next-700.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/atkinson-mono-400.woff2") format("woff2"); }

:root {
  --teal: #0bb5b0;
  --deep-teal: #04302f;
  --teal-pale: #e7f8f7;
  --teal-text: #077370;
  --text-muted: #3d5c5b;
  --white: #ffffff;
  --rule: #9fb3b2;
  --font-head: Overpass, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, Menlo, Consolas, monospace;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.875rem;
  --tap: 2.75rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--teal-pale);
  color: var(--deep-teal);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 800; margin: 0 0 var(--space-3); }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.375rem; line-height: 1.27; }
h3 { font-size: 1.1875rem; line-height: 1.26; }
/* User-entered text (company, person, address, SWMS number and title) is Atkinson, never Overpass, even in a heading. */
.name { font-family: var(--font-body); }
p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 var(--space-3); padding-left: var(--space-6); }
a { color: var(--teal-text); text-underline-offset: 0.15em; }
:focus-visible { outline: 3px solid var(--deep-teal); outline-offset: 2px; }
[hidden] { display: none !important; }
img, svg { max-width: 100%; }

/* Layout: one column, centred. */
.page { max-width: 40rem; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-8); }
.page-wide { max-width: 64rem; }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; line-height: 1.43; }
.mono { font-family: var(--font-mono); }
.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; }

/* Header and wordmark. SWMSlink is one word only here (DESIGN.md Logo). */
.site-header { background: var(--white); border-bottom: 1px solid var(--rule); }
.site-header .inner { max-width: 64rem; margin: 0 auto; padding: var(--space-2) var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; justify-content: space-between; }
.site-nav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); align-items: center; }
.site-nav a, .site-nav .linkish { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 700; }
.wordmark { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); color: var(--deep-teal); text-decoration: none; font-family: var(--font-head); font-size: 1.375rem; letter-spacing: -0.01em; isolation: isolate; }
.wordmark img { width: 1.75rem; height: 1.75rem; }
.wm-swms { font-weight: 900; }
.wm-link { position: relative; font-weight: 400; }
.wm-link::before { content: ""; position: absolute; left: -0.06em; right: -0.06em; bottom: 0.08em; height: 0.42em; background: var(--teal); border-radius: 0.08em; transform: skewX(-12deg) rotate(-2deg); z-index: -1; }
.wm-l { font-family: var(--font-body); font-weight: 500; }

/* Buttons: a solid block with a clear verb, at least 44px high. */
button { font: inherit; }
.btn, .btn-teal, .btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); min-width: var(--tap); padding: var(--space-2) var(--space-4);
  border: 2px solid var(--deep-teal); border-radius: var(--radius-md);
  font-family: var(--font-body); font-size: 1rem; font-weight: 700; line-height: 1.375;
  text-align: center; text-decoration: none; cursor: pointer;
  max-width: 100%; overflow-wrap: anywhere;
}
.btn { background: var(--deep-teal); color: var(--white); }
.btn-teal { background: var(--teal); color: var(--deep-teal); }
.btn-quiet { background: var(--white); color: var(--deep-teal); }
.btn-block { width: 100%; }
.btn[disabled], .btn-teal[disabled], .btn-quiet[disabled] { opacity: 0.55; cursor: not-allowed; }
.linkish { display: inline; min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--teal-text); font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Forms: label above, white field, muted border. */
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
/* A date field has a wide built-in minimum; at 200% text on a 320 px phone it must shrink to the column. */
input[type="date"] { min-width: 0; max-width: 100%; }
.field > label, legend { font-weight: 700; line-height: 1.375; }
.hint { margin: 0; color: var(--text-muted); font-size: 0.875rem; line-height: 1.43; }
.field-error { margin: 0; font-weight: 700; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="tel"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 0.625rem 0.75rem;
  border: 1px solid var(--text-muted); border-radius: var(--radius-md);
  background: var(--white); color: var(--deep-teal); font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
[aria-invalid="true"] { border: 2px solid var(--deep-teal); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: var(--space-2); }
.choices { display: grid; gap: var(--space-2); }
.choice { display: flex; gap: var(--space-3); align-items: flex-start; min-height: var(--tap); padding: var(--space-3); background: var(--white); border: 1px solid var(--text-muted); border-radius: var(--radius-md); cursor: pointer; }
.choice input { flex: none; width: 1.375rem; height: 1.375rem; margin: 0.0625rem 0 0; accent-color: var(--deep-teal); }
.choice:has(input:checked) { border: 2px solid var(--deep-teal); background: var(--teal-pale); }
.choice:has(input:disabled) { cursor: default; }

/* Panels and messages. Errors use words and a deep-teal edge, never a safety colour (ruling P1). */
.card { background: var(--white); border-radius: var(--radius-lg); padding: var(--space-4); }
.card-bordered { border: 1px solid var(--text-muted); }
.notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); background: var(--white); border: 2px solid var(--deep-teal); border-radius: var(--radius-md); }
.notice-info { background: var(--teal-pale); border-width: 1px; }
.notice > div { min-width: 0; }
.badge { display: inline-block; flex: none; padding: 0 var(--space-2); border-radius: var(--radius-sm); font-weight: 700; line-height: 1.5; }
.badge-solid { background: var(--deep-teal); color: var(--white); }
.badge-outline { border: 1px solid var(--deep-teal); }
.safety-tag { display: inline-flex; gap: var(--space-2); align-items: center; font-weight: 700; }
.safety-tag svg { flex: none; width: 1.5rem; height: 1.5rem; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); margin: 0; }
.kv dt { font-weight: 700; }
.kv dd { margin: 0 0 var(--space-2); }

/* Wizard */
.wizard-top { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.step-count { margin: 0; font-weight: 700; color: var(--text-muted); }
.steps-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.steps-list a { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-md); color: var(--deep-teal); text-decoration: none; }
.steps-list a[aria-current="step"] { background: var(--white); border: 2px solid var(--deep-teal); font-weight: 700; }
.step-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between; margin-top: var(--space-6); }
.suggestions { list-style: none; margin: 0; padding: 0; background: var(--white); border: 1px solid var(--text-muted); border-radius: var(--radius-md); overflow: hidden; }
.suggestions li + li { border-top: 1px solid var(--rule); }
.suggestions button { display: block; width: 100%; min-height: var(--tap); padding: var(--space-2) var(--space-3); background: none; border: 0; color: var(--deep-teal); text-align: left; cursor: pointer; }
.attribution { margin: 0; padding: var(--space-1) var(--space-3); color: var(--text-muted); font-size: 0.875rem; }

/* Review lines */
.line { background: var(--white); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); }
.line[data-status="pending"] { border: 2px solid var(--deep-teal); }
.line[data-removed="true"] { background: var(--teal-pale); color: var(--text-muted); }
/* Lines nest three deep (step, hazard, control); at 320 px and 200% text, full padding at each level leaves no room. */
.line .line { padding: var(--space-2) var(--space-2); }
.line .controls { margin-top: var(--space-2); }
.line .notice { flex-wrap: wrap; padding: var(--space-2); }
.line .line-actions > * { padding-inline: var(--space-2); }
.line-head { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: space-between; }
.line-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.level-tag { display: inline-block; padding: 0 0.375rem; border: 1px solid var(--deep-teal); border-radius: var(--radius-sm); font-weight: 700; }
.controls { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }

/* Preview: the SWMS document in a frame. The measuring frame is the PDF's content width (A4 less 12 mm margins). */
.preview-frame { display: block; width: 100%; height: 70vh; background: var(--white); border: 1px solid var(--text-muted); border-radius: var(--radius-md); }
.measure-frame { position: absolute; top: 0; left: -10000px; width: 186mm; height: 10rem; border: 0; visibility: hidden; }

/* SWMS list */
.swms-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.swms-list a { display: block; padding: var(--space-4); background: var(--white); border-radius: var(--radius-lg); color: var(--deep-teal); text-decoration: none; }
.swms-list a:hover { outline: 2px solid var(--deep-teal); }

@media (min-width: 40rem) {
  .kv { grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); }
  .kv dd { margin: 0; }
}
details > summary { display: flex; align-items: center; min-height: var(--tap); cursor: pointer; font-weight: 700; }
.save-status { margin: 0; min-height: 1.5rem; color: var(--text-muted); font-size: 0.875rem; }
.step-lock { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Terms and privacy pages */
.legal h1 { margin-top: var(--space-4); }
.legal h2 { margin-top: var(--space-6); }
.legal table { width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--white); }
.legal th, .legal td { padding: var(--space-2); text-align: left; vertical-align: top; border-top: 1px solid var(--rule); }
.legal hr { border: 0; border-top: 1px solid var(--rule); }
