/* ==========================================================================
   TourShare — shared styles
   Based on plan files/DESIGN.md, with accessibility overrides from PRODUCT.md:
   18px minimum body text, white high-contrast fields, 48px+ tap targets.
   ========================================================================== */

:root {
  /* Brand */
  --primary: #2a72de;          /* action blue: ONE primary button per view */
  --primary-press: #1f5fbf;
  --on-primary: #ffffff;
  --stone: #4a4741;            /* workhorse neutral: wordmark, secondary buttons, links */
  --stone-press: #36332e;
  --clay: #6b443d;
  --espresso: #39221e;
  --gold: #af751b;
  --gold-soft: #ddaa61;
  --gold-pale: #ddbe78;
  --forest: #224228;
  --olive: #5c6f5d;
  --sage: #849671;
  --sage-pale: #ced4b8;

  /* Surfaces */
  --canvas: #f7f1e8;           /* warm paper: default background */
  --surface: #ffffff;          /* cards and inputs only */
  --hairline: #e1dcd3;
  --field-border: #8a857c;     /* darker than hairline so fields are easy to find (3:1 on white) */
  --ink-band: #19191c;

  /* Text */
  --ink: #1c1b1a;
  --text-2: #4a4741;           /* secondary text uses stone, not grey, to keep 7:1+ */
  --on-dark: #ffffff;
  --on-dark-2: #cfcac2;

  /* Feedback */
  --error: #b42c18;            /* darkened from #e33a22 so error text passes 4.5:1 */
  --error-bg: #fbeae6;
  --success: #224228;

  /* Type */
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 24px;
  --r-xl: 40px;
  --r-full: 9999px;

  /* Spacing (8px base) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* Depth: soft, warm, low-opacity */
  --shadow-1: 0 2px 6px rgba(57, 34, 30, 0.05), 0 8px 24px rgba(57, 34, 30, 0.06);
  --shadow-2: 0 4px 12px rgba(57, 34, 30, 0.06), 0 20px 48px rgba(57, 34, 30, 0.10);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --focus: 0 0 0 3px var(--canvas), 0 0 0 6px var(--primary);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: #b9b1a4 var(--canvas);   /* themed scrollbar on cream */
}
html:has(body.viewer) { scrollbar-color: #4a4741 var(--ink-band); }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;          /* 18px */
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--primary);
}

::selection { background: var(--gold-pale); color: var(--espresso); }

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

a {
  color: var(--stone);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.22em;
}
a:hover { color: var(--ink); }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }

h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Type scale ---------- */
.display {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem);   /* 40 → 68px */
  line-height: 1.08;
  letter-spacing: -0.015em;
}
.display em { font-style: italic; font-weight: 300; }

.heading-2 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2rem, 1.6rem + 1.6vw, 2.5rem);      /* 32 → 40px */
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lead {
  font-size: 1.25rem;            /* 20px */
  line-height: 1.5;
  color: var(--text-2);
}

.small { font-size: 1rem; line-height: 1.5; color: var(--text-2); }   /* 16px floor */

/* ---------- Wordmark ---------- */
.wordmark {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  color: var(--stone);
  text-decoration: none;
  line-height: 1;
}
.wordmark__name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}
.wordmark__name i { font-style: italic; font-weight: 300; }
.wordmark__by {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-2);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  width: 100%;
  padding: var(--s-4) var(--s-4);
  max-width: 1440px;
  margin: 0 auto;
}

/* ---------- App bar (logged-in pages) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
}
.appbar__inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  max-width: 1200px; margin: 0 auto;
  padding: var(--s-3) var(--s-4);
}
.appbar__nav { display: flex; align-items: center; gap: var(--s-2); }
.appbar__link {
  display: none;
  align-items: center; min-height: 48px; padding: 0 var(--s-4);
  border-radius: var(--r-full);
  font-weight: 600; font-size: 1.0625rem;
  color: var(--stone); text-decoration: none;
}
.appbar__link:hover { background: rgba(74, 71, 65, 0.07); color: var(--ink); }
.appbar__link[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--hairline); color: var(--ink); }
.avatar {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--stone); color: var(--on-dark);
  font-weight: 600; font-size: 1.0625rem; letter-spacing: 0.02em;
  text-decoration: none;
}
.avatar:hover { background: var(--stone-press); color: var(--on-dark); }
.avatar:focus-visible { border-radius: 50%; }

.backlink {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 48px; margin-left: -6px; padding-right: var(--s-3);
  font-weight: 600; font-size: 1.0625rem;
  color: var(--stone); text-decoration: none;
}
.backlink svg { width: 24px; height: 24px; }
.backlink:hover { color: var(--ink); }

@media (min-width: 768px) {
  .appbar__inner { padding: var(--s-3) var(--s-6); }
  .appbar__link { display: inline-flex; }
}

/* ---------- Buttons ---------- */
.btn {
  --h: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: var(--h);
  padding: 0 var(--s-6);
  border: 2px solid transparent;
  border-radius: var(--r-full);
  font-family: var(--sans);
  font-size: 1.1875rem;          /* 19px */
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn:focus-visible { box-shadow: var(--focus); border-radius: var(--r-full); }
.btn svg { width: 24px; height: 24px; flex: none; }

.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-press); color: var(--on-primary); }

.btn--secondary { background: var(--stone); color: var(--on-dark); }
.btn--secondary:hover { background: var(--stone-press); color: var(--on-dark); }

.btn--outline { background: transparent; color: var(--stone); border-color: var(--stone); }
.btn--outline:hover { background: rgba(74, 71, 65, 0.06); color: var(--ink); }

.btn--small { --h: 48px; padding: 0 var(--s-5); font-size: 1.0625rem; }
.btn--block { display: flex; width: 100%; }

.btn[aria-busy="true"] { cursor: progress; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--s-2); }

.field__label {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
}

.field__hint { font-size: 1rem; color: var(--text-2); }

.input {
  width: 100%;
  min-height: 60px;
  padding: 0 var(--s-4);
  background: var(--surface);
  border: 2px solid var(--field-border);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 1.1875rem;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input::placeholder { color: #6f6a62; }
.input:hover { border-color: var(--stone); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(42, 114, 222, 0.18); }

.field.is-invalid .input { border-color: var(--error); background: #fffdfc; }
.field.is-invalid .input:focus { box-shadow: 0 0 0 4px rgba(180, 44, 24, 0.15); }

.field__error {
  display: none;
  align-items: flex-start;
  gap: var(--s-2);
  font-size: 1rem;
  font-weight: 600;
  color: var(--error);
}
.field__error svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.field.is-invalid .field__error { display: flex; }

.textarea {
  width: 100%; min-height: 110px;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 2px solid var(--field-border);
  border-radius: var(--r-md);
  font: inherit; font-size: 1.125rem; color: var(--ink);
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.textarea::placeholder { color: #6f6a62; }
.textarea:hover { border-color: var(--stone); }
.textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(42, 114, 222, 0.18); }

/* Large consent checkbox: the whole row is the tap target */
.check {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: var(--s-4);
  align-items: start;
  padding: var(--s-4);
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.check:hover { border-color: var(--field-border); }
.check input {
  position: absolute; opacity: 0;
  width: 1px; height: 1px;
}
.check__box {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 2px solid var(--field-border);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: background-color 180ms var(--ease-out), border-color 180ms ease;
}
.check__box svg {
  width: 22px; height: 22px;
  color: #fff;
  stroke-dasharray: 24; stroke-dashoffset: 24;
  transition: stroke-dashoffset 260ms var(--ease-out) 40ms;
}
.check input:checked + .check__box { background: var(--forest); border-color: var(--forest); }
.check input:checked + .check__box svg { stroke-dashoffset: 0; }
.check input:focus-visible + .check__box { box-shadow: var(--focus); }
.check:has(input:checked) { border-color: var(--sage); background: #fbfcf7; }
.check__text { font-size: 1.125rem; line-height: 1.45; padding-top: 2px; }
.check__text a { position: relative; z-index: 1; }
.field.is-invalid .check { border-color: var(--error); }
/* Radio variant: round box with a dot */
.check--radio .check__box { border-radius: 50%; }
.check--radio .check__box svg { stroke-dasharray: none; stroke-dashoffset: 0; opacity: 0; transition: opacity 160ms ease; }
.check--radio input:checked + .check__box { background: var(--surface); border-color: var(--forest); }
.check--radio input:checked + .check__box svg { opacity: 1; }
.check--radio input:disabled ~ * { opacity: .6; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink-band);
  color: var(--on-dark-2);
  padding: var(--s-7) var(--s-4) var(--s-6);
}
.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: var(--s-5);
}
.site-footer .wordmark { color: var(--on-dark); }
.site-footer .wordmark__by { color: var(--on-dark-2); }
.site-footer nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5);
}
.site-footer nav a {
  display: inline-flex; align-items: center;
  min-height: 48px;
  color: var(--on-dark);
  font-size: 1.0625rem;
}
.site-footer small { font-size: 1rem; color: var(--on-dark-2); }

@media (min-width: 768px) {
  .topbar { padding: var(--s-5) var(--s-6); }
  .site-footer { padding: var(--s-8) var(--s-6) var(--s-6); }
  .site-footer__inner { grid-template-columns: 1fr auto; align-items: center; }
  .site-footer small { grid-column: 1 / -1; padding-top: var(--s-5); border-top: 1px solid #33322f; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Dialogs (bottom sheets), danger button, toast: shared ---------- */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%; max-width: 100%;
  max-height: 92vh;
  margin: 0;
  overflow-y: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--canvas);
  color: var(--ink);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet[open] { animation: sheet-up 380ms var(--ease-out); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet__body { display: grid; gap: var(--s-5); padding: var(--s-6) var(--s-5) calc(var(--s-5) + env(safe-area-inset-bottom)); }
.sheet__grab { width: 48px; height: 5px; border-radius: 3px; background: #d6cfc2; margin: 0 auto calc(var(--s-2) * -1); }
.sheet h2 { font-family: var(--serif); font-weight: 400; font-size: 1.875rem; line-height: 1.15; }
.sheet p { color: var(--text-2); }
.sheet__actions { display: grid; gap: var(--s-3); }
.sheet fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.sheet legend { font-weight: 600; margin-bottom: var(--s-3); padding: 0; }
.btn--danger { background: var(--error); color: #fff; }
.btn--danger:hover { background: #962412; color: #fff; }

.thanks { display: grid; justify-items: start; gap: var(--s-4); }
.thanks__icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--sage-pale); color: var(--forest); }
.thanks__icon svg { width: 36px; height: 36px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--s-5) + env(safe-area-inset-bottom)); z-index: 50;
  display: flex; align-items: center; gap: var(--s-3);
  width: max-content; max-width: calc(100% - 32px);
  padding: var(--s-3) var(--s-5) var(--s-3) var(--s-4);
  background: var(--canvas); color: var(--ink);
  border-radius: var(--r-full);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-weight: 600;
  transform: translate(-50%, calc(100% + 64px));
  visibility: hidden;
  transition: transform 420ms var(--ease-out), visibility 0s linear 420ms;
}
.toast.is-shown { transform: translate(-50%, 0); visibility: visible; transition: transform 420ms var(--ease-out); }
.toast svg { width: 26px; height: 26px; flex: none; color: var(--forest); }
@media (min-width: 1024px) {
  .sheet { inset: 0; width: 560px; height: fit-content; margin: auto; border-radius: var(--r-lg); }
  .sheet__grab { display: none; }
}

[hidden] { display: none !important; }
