/* =============================================================================
   base.css — the fluid foundation. Copy into every site as css/base.css.
   Nothing here is width-locked: type, spacing and layout scale continuously
   from ~360px phones to ultrawide. This file is why sites are dynamic off the bat.
   ============================================================================= */

:root {
  /* COLOURS — Mosaique brand (from the mosaic artwork + design PDF). Heading brown sampled from the design. */
  --cream:  #F3EFEB;
  --sage:   #CAD6D2;
  --teal:   #728C8B;
  --amber:  #F0B349;
  --orange: #D98C33;
  --brown:  #865227;
  --brand:      var(--teal);      /* primary (buttons, active states) */
  --brand-dark: #5E7776;          /* darker primary (hovers) */
  --accent:     var(--orange);    /* accent / highlight (eyebrows, nav links) */
  --muted:      #9A7B5E;          /* secondary text — lighter brown */
  --surface:    var(--cream);     /* light section background */
  --ink:        var(--brown);     /* body text */
  --white:      #ffffff;

  /* TYPE — fluid scale. Never set a size that only looks right at one width. */
  --font:         "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;   /* body — Google Fonts, linked in head.php */
  --font-display: "Margem", "Montserrat", system-ui, sans-serif;                            /* headings — self-hosted, @font-face in css/site.css */
  --t-header: clamp(48px, 7vw,   88px);
  --t-h1:     clamp(40px, 5.4vw, 70px);
  --t-h2:     clamp(30px, 3.6vw, 46px);
  --t-h3:     clamp(25px, 2.6vw, 32px);
  --t-lg:   20px;
  --t-body: 17px;
  --t-small: 11px;
  --t-cta:   12px;

  /* SPACING — gutters and section rhythm breathe with the viewport. */
  --wrap: 1240px;                             /* max content width; page itself is fluid */
  --pad:  clamp(20px, 5vw, 64px);             /* fluid side padding */
  --section-y: clamp(56px, 8vw, 128px);       /* vertical section rhythm */
  --measure: 68ch;                            /* readable line-length cap */

  --nav-h: 80px;                              /* solid bar height at rest (site.css compacts it on scroll) */
  --radius: 10px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ── Minimal reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
/* overscroll-behavior-y: none kills the rubber-band bounce / pull-to-refresh at the top/bottom.
   It MUST be on the scroll container itself — that's <html>, not just <body> — or it does nothing.
   Set on both. (Desktop Safari treats the top bounce as a system behaviour and ignores this; it
   works in Chrome/Edge/Firefox and, to a degree, mobile Safari.) */
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; overscroll-behavior-y: none; }
body {
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;                         /* body never gets a horizontal scrollbar */
  overflow-wrap: break-word;                  /* long words wrap instead of overflowing (else clipped by overflow-x) */
  overscroll-behavior-y: none;                /* no rubber-band bounce (see note above; must also be on <html>) */
}
img, picture, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Typography scale ──────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; }   /* Margem ships as Medium (500) only */
h1 { font-size: var(--t-h1); line-height: 1.05; }
h2 { font-size: var(--t-h2); line-height: 1.12; }
h3 { font-size: var(--t-h3); line-height: 1.2; }
p  { max-width: var(--measure); }
/* Unbreakable tokens (URLs, emails, long single words) break instead of running off narrow screens. */
a, h1, h2, h3, h4, h5, h6, td, li { overflow-wrap: anywhere; }
.eyebrow { font-size: var(--t-cta); letter-spacing: 0; color: var(--accent); font-weight: 700; }

/* ── Layout helpers ────────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--pad); }
.section { padding-block: var(--section-y); }
.section--surface { background: var(--surface); }
.measure { max-width: var(--measure); }
.stack > * + * { margin-top: 1rem; }
.center { text-align: center; margin-inline: auto; }
.center p { margin-inline: auto; }   /* p has a max-width (--measure), so centre the box, not just its text */

/* Auto-fit grid that never overflows: cells wrap when they can't hold min width. */
.grid { display: grid; gap: clamp(16px, 3vw, 32px); }
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }

/* Wide content (tables/code/diagrams) scrolls inside its own box, never the page. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5em; padding: .9em 1.6em; border: 1px solid transparent; border-radius: var(--radius);
  font-size: var(--t-cta); letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-fill    { background: var(--brand); color: var(--white); }
.btn-fill:hover  { background: var(--brand-dark); }
.btn-outline { background: transparent; color: var(--brand); border-color: currentColor; }
.btn-outline:hover { background: var(--brand); color: var(--white); }

/* ── Submit busy state (main.js adds .is-loading + injects the spinner span) ─────
   MANDATORY on every form submit button (spec §8). A submit can legitimately take
   many seconds — process.php retries the Markt delivery before it answers — and a
   merely-disabled button reads as "this button is broken", so visitors re-click or
   leave. The swapped LABEL is what carries the state: the global reduced-motion rule
   above freezes every animation, so the spinner must never be the only signal.
   main.js also sets aria-busy for assistive tech.

   Standalone classes, not nested under .btn: a project's submit button is not always
   a .btn. .btn is inline-flex with a .5em gap, so the spinner needs no margin here —
   if you apply it to a NON-flex button, add `margin-right: .5em` there. */
.is-loading[aria-busy="true"] { cursor: progress; }
.btn__spinner {
  width: 1em; height: 1em; flex: none;
  border: 2px solid currentColor;
  border-top-color: transparent;   /* the gap that makes the rotation legible */
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── Hero (100svh so mobile chrome doesn't clip it) ───────────────────────────── */
.hero {
  position: relative; min-height: 100vh; min-height: 100svh;   /* vh fallback for Safari < 15.4 */
  display: grid; place-items: center; text-align: center;
  color: var(--white); overflow: hidden;
}
.hero__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; z-index: -2; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.55)); z-index: -1; }
.hero__inner { padding: var(--pad); display: grid; gap: 1.2rem; justify-items: center; }
.hero h1 { font-size: var(--t-header); }

/* ── Navigation ────────────────────────────────────────────────────────────── */
.nav { position: fixed; inset: 0 0 auto; z-index: 40; transition: transform .3s var(--ease), background .3s var(--ease); }
.nav__bar { display: flex; align-items: center; gap: 1rem; min-height: var(--nav-h); }
.nav__logo { font-weight: 800; letter-spacing: .04em; font-size: var(--t-lg); }
.nav__links { display: flex; gap: clamp(12px, 2vw, 28px); margin-left: auto; }
.nav__links a { font-size: var(--t-cta); letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.nav__cta { padding-block: .6em; }
/* Homepage bar: transparent over hero, solid once scrolled. Sub-page bar: always solid. */
.nav:not(.nav--static) { background: transparent; color: var(--white); }
.nav.nav--static, .nav.is-scrolled { background: var(--white); color: var(--ink); box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.nav.nav--static .nav__cta, .nav.is-scrolled .nav__cta { background: var(--brand); color: var(--white); }

.nav__burger { display: none; flex-direction: column; justify-content: center; align-items: center; gap: 5px; background: none; border: 0; padding: 8px; min-width: 44px; min-height: 44px; }
.nav__burger span { width: 24px; height: 2px; background: currentColor; }

/* Drawer */
.drawer-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50;
  opacity: 0; visibility: hidden; transition: opacity .4s var(--ease), visibility 0s .4s;
}
.drawer-scrim.is-open { opacity: 1; visibility: visible; transition: opacity .4s var(--ease), visibility 0s; }
.drawer {
  --drawer-ease: cubic-bezier(.32,.72,0,1);   /* iOS-sheet style: fast start, long soft settle */
  position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: min(86vw, 340px);
  background: var(--white); color: var(--ink); z-index: 60; padding: clamp(24px, 6vw, 48px);
  transform: translateX(100%); transition: transform .5s var(--drawer-ease), visibility 0s .5s; visibility: hidden;
  will-change: transform;
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: none; visibility: visible; transition: transform .5s var(--drawer-ease), visibility 0s; }
/* Links drift in just behind the panel */
.drawer__links > *, .drawer .lang-row { opacity: 0; transform: translateX(24px); transition: opacity .3s var(--ease), transform .3s var(--ease); }
.drawer.is-open .drawer__links > *, .drawer.is-open .lang-row { opacity: 1; transform: none; transition-duration: .5s; }
.drawer.is-open .drawer__links > *:nth-child(1) { transition-delay: .12s; }
.drawer.is-open .drawer__links > *:nth-child(2) { transition-delay: .16s; }
.drawer.is-open .drawer__links > *:nth-child(3) { transition-delay: .20s; }
.drawer.is-open .drawer__links > *:nth-child(4) { transition-delay: .24s; }
.drawer.is-open .drawer__links > *:nth-child(5) { transition-delay: .28s; }
.drawer.is-open .drawer__links > *:nth-child(n+6), .drawer.is-open .lang-row { transition-delay: .32s; }
.drawer__close { align-self: flex-end; display: grid; place-items: center; min-width: 44px; min-height: 44px; font-size: 32px; line-height: 1; background: none; border: 0; color: inherit; }
.drawer__links { display: flex; flex-direction: column; gap: 1.2rem; margin-top: 2rem; font-size: var(--t-lg); }

@media (max-width: 860px) {
  .nav__links, .nav__cta { display: none; }
  .nav__burger { display: flex; }
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.footer { background: var(--brand-dark); color: var(--white); padding-block: clamp(40px, 6vw, 72px); }
.footer__inner { display: grid; gap: 1.4rem; justify-items: center; text-align: center; }
.footer__legal { display: flex; gap: .8rem; flex-wrap: wrap; justify-content: center; font-size: var(--t-cta); letter-spacing: .06em; text-transform: uppercase; }
.footer__social { display: flex; gap: 1rem; list-style: none; padding: 0; }
.footer__social a { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; transition: background .2s; }
.footer__social a:hover { background: rgba(255,255,255,.12); }
.footer__copy { font-size: 13px; opacity: .8; line-height: 1.8; max-width: none; }
.footer__copy a { text-decoration: underline; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form { display: grid; gap: 1rem; max-width: 560px; }
.form__row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.form label { display: grid; gap: .4rem; font-size: 14px; }
.form input, .form select, .form textarea {
  font: inherit; font-size: 16px; padding: .8em 1em; border: 1px solid #cfcfcf; border-radius: var(--radius); background: var(--white); width: 100%;  /* font-size >=16px so iOS Safari doesn't zoom on focus */
}
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--accent); outline: none; }
.form__consent { display: flex; gap: .6rem; align-items: flex-start; font-size: 13px; }
.form__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }  /* honeypot */
.form__msg { font-size: 14px; }
.form__msg.is-error { color: #b0261a; }

/* Body offset so fixed nav never covers content on sub-pages. */
.has-static-nav { padding-top: var(--nav-h); }

/* ── Legal pages (privacy / terms) — long-form readable typography ─────────────── */
.legal { max-width: 80rem; }
.legal p { max-width: none; }
.legal h1 { font-size: var(--t-h2); }
.legal h2 { font-size: var(--t-h3); margin-top: 2.2rem; }
.legal h3 { font-size: var(--t-lg); margin-top: 1.6rem; }
.legal p, .legal ul, .legal ol { margin-top: 1rem; }
.legal ul, .legal ol { padding-left: 1.4rem; }
.legal li { margin-top: .4rem; }
.legal a { color: var(--brand); text-decoration: underline; }

/* ── Image-layout repertoire — frames, captions, galleries (immersive, not stiff) ── */
.media-frame { position: relative; overflow: hidden; border-radius: var(--radius); }
.media-frame img { width: 100%; height: 100%; object-fit: cover; }
.media-cap { position: absolute; inset: auto 0 0 0; padding: 1rem 1.2rem; color: var(--white);
  background: linear-gradient(0deg, rgba(0,0,0,.6), transparent); font-weight: 600; pointer-events: none; }
.gallery { display: grid; gap: clamp(12px, 2vw, 24px); grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.gallery-frame { position: relative; overflow: hidden; border-radius: var(--radius); aspect-ratio: 4 / 3; }
.gallery-frame img { width: 100%; height: 100%; object-fit: cover; }

/* ── Reduced motion: every animation must have a no-motion path (spec §1.5). ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
