/*
  base.css — shared structure. NO colours or fonts are defined here.
  Every visual value comes from tokens that each site's css/styles.css defines:

    --bg --surface --surface-2 --ink --muted --line --accent --accent-ink
    --focus --danger --danger-ink --ok --ok-ink --warn
    --font-body --font-display --radius --radius-sm --shadow --ease --maxw

  Paste this file at the top of a site's styles.css (after the tokens) or link it first.
*/

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-size: 100%; scroll-padding-top: 6rem; }
html[data-text="lg"] { font-size: 112.5%; }
html[data-text="xl"] { font-size: 125%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--font-body); line-height: 1.6; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; text-wrap: balance; }
p { margin: 0 0 1em; }
a { color: inherit; text-underline-offset: .18em; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* Skip link + focus */
.skip-link { position: absolute; left: 1rem; top: -100px; z-index: 1000; padding: .75rem 1rem; background: var(--ink); color: var(--bg); border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
main:focus { outline: none; }

/* Utilities */
.container { width: 100%; max-width: var(--maxw, 1200px); margin-inline: auto; padding-inline: 1.25rem; }
@media (min-width: 768px) { .container { padding-inline: 2rem; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack > * + * { margin-top: var(--stack, 1rem); }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Buttons (shape only; sites style colour) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px; padding: .7em 1.3em; border: 2px solid transparent; border-radius: var(--radius); text-decoration: none; font-weight: 600; line-height: 1.2; transition: transform .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--danger { background: var(--danger); color: var(--danger-ink); }
.btn--small { min-height: 36px; padding: .4em .9em; font-size: .9rem; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* Header + nav structure */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--bg); transition: box-shadow .2s var(--ease), background-color .2s var(--ease); }
.site-header.is-scrolled { box-shadow: var(--shadow); }
.header-bar { display: flex; align-items: center; gap: 1rem; min-height: 68px; }
.header-tools { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.burger { display: inline-grid; }
@media (max-width: 899px) {
  .site-nav { position: fixed; inset: 68px 0 auto 0; max-height: calc(100vh - 68px); overflow-y: auto; background: var(--bg); border-top: 1px solid var(--line); padding: 1rem 1.25rem 2rem; transform: translateY(-120%); visibility: hidden; transition: transform .25s var(--ease), visibility 0s linear .25s; box-shadow: var(--shadow); }
  .site-nav.is-open { transform: none; visibility: visible; transition: transform .25s var(--ease); }
  .site-nav li a { display: block; padding: .85rem 0; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 1.15rem; }
}
@media (min-width: 900px) {
  .burger { display: none; }
  .site-nav ul { display: flex; gap: 1.5rem; align-items: center; }
  .site-nav a { text-decoration: none; padding: .4rem 0; }
}
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .35em; }

/* Display menu (text size + theme) */
.display-menu { position: relative; }
.display-menu > summary { list-style: none; }
.display-menu > summary::-webkit-details-marker { display: none; }
.display-panel { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 60; width: 15rem; padding: 1rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.display-panel fieldset { border: 0; margin: 0 0 .75rem; padding: 0; }
.display-panel legend { font-weight: 700; margin-bottom: .4rem; }
.display-panel label { display: flex; gap: .5rem; align-items: center; padding: .25rem 0; cursor: pointer; }

/* Forms */
.field { display: grid; gap: .35rem; margin-bottom: 1.1rem; }
.field > label, .field > legend, .label { font-weight: 600; }
.hint { font-size: .9rem; color: var(--muted); margin: 0; }
.input, input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], input[type="time"], input[type="url"], select, textarea {
  width: 100%; min-height: 48px; padding: .65rem .85rem; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: var(--radius-sm); }
textarea { min-height: 120px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], fieldset[aria-invalid="true"] { border-color: var(--danger); }
fieldset[aria-invalid="true"] { border-left: 3px solid var(--danger); padding-left: .75rem; }
.field-error { margin: 0; color: var(--danger); font-weight: 600; font-size: .92rem; }
.field-error::before { content: "⚠ "; }
.field-error:empty { display: none; }
fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
.check { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: .2rem; flex: none; accent-color: var(--accent); }
.form-grid { display: grid; gap: 0 1rem; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .span-2 { grid-column: 1 / -1; } }

/* Toasts */
.toasts { position: fixed; z-index: 400; right: 1rem; bottom: 1rem; left: 1rem; display: grid; gap: .5rem; justify-items: end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: .75rem; align-items: center; max-width: 26rem; padding: .8rem 1rem; background: var(--ink); color: var(--bg); border-radius: var(--radius-sm); box-shadow: var(--shadow); animation: toast-in .25s var(--ease); }
.toast--error { background: var(--danger); color: var(--danger-ink); }
.toast--ok { background: var(--ok); color: var(--ok-ink); }
.toast__close { background: none; border: 0; color: inherit; font-size: 1.3rem; line-height: 1; padding: .25rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dialog */
.dialog { width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog__inner { position: relative; padding: 1.5rem; }
.dialog__title { font-size: 1.35rem; padding-right: 2.5rem; }
.dialog__x { position: absolute; top: .75rem; right: .75rem; width: 40px; height: 40px; background: none; border: 0; font-size: 1.6rem; color: inherit; border-radius: var(--radius-sm); }
.dialog__actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
.dialog--wide { width: min(60rem, calc(100vw - 2rem)); }

/* Cookie banner */
.cookie-banner { position: fixed; z-index: 300; left: 1rem; right: 1rem; bottom: 1rem; max-width: 40rem; margin-inline: auto; padding: 1.25rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cookie-banner__title { font-size: 1.15rem; }
.cookie-banner p { font-size: .95rem; }
.cookie-banner__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.cookie-banner__custom { display: grid; gap: .5rem; margin-bottom: 1rem; padding: .75rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.cookie-banner__custom .btn { justify-self: start; }

/* Concept-demo banner */
.demo-banner { position: relative; z-index: 60; display: flex; align-items: center; justify-content: center; gap: .75rem; padding: .5rem 3rem .5rem 1rem; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: .85rem; line-height: 1.4; text-align: center; background: var(--demo-bg, var(--ink)); color: var(--demo-ink, var(--bg)); }
.demo-banner p { margin: 0; }
.demo-banner a { color: inherit; font-weight: 700; }
.demo-banner button { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; background: none; border: 0; color: inherit; font-size: 1.3rem; border-radius: 4px; }

/* Tables (admin) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.table th, .table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }

/* Reveal (content is visible without JS) */
@media (prefers-reduced-motion: no-preference) {
  .reveal--pending { opacity: 0; transform: translateY(18px); }
  .reveal--pending.is-in { opacity: 1; transform: none; transition: opacity .7s var(--ease), transform .7s var(--ease); }
}

/* Reduced motion: no animation anywhere */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Print */
@media print {
  .site-header, .site-footer, .demo-banner, .cookie-banner, .toasts, .no-print, .tapbar { display: none !important; }
  body { background: #fff; color: #000; }
  a { text-decoration: none; }
}
