/* Grand Tour Italy website. One stylesheet; every colour, size and space is a
   token, named after the design-system variables (README.md lists them, and
   the Figma file uses the same names).
   Palette: the app's Modern Maiolica (lib/theme/app_theme.dart). Dark is its
   own palette, not the light one inverted. Every text pair is AA or better,
   checked when the tokens were set (README.md, "Contrast").
   Shape rule: controls 10px, cards 12px, photos and panels 20px, phone
   frames 36px. Nothing else. */

:root {
  /* Colour, light */
  --surface: #faf7ee;            /* limestone */
  --surface-alt: #ffffff;
  --on-surface: #263c51;         /* navy */
  --on-surface-muted: #4f5f6e;
  --primary: #263c51;
  --primary-contrast: #faf7ee;
  --accent: #f2ebc6;             /* soft lemon */
  --accent-contrast: #263c51;
  --sky: #dce8f1;
  --divider: #d8d1bd;
  --danger: #b3261e;
  --success: #2e6b3a;
  --photo-caption-bg: #ffffff;
  --link: #1d5a85;
  --focus: #1d5a85;
  --bezel: #1b2b3b;              /* phone frame */
  --shadow-tint: 38 60 81;       /* navy, for tinted shadows */

  /* Type ramp (px) and families: system fonts only, nothing downloaded */
  --font-heading: Georgia, "Noto Serif", "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --text-12: 0.75rem;
  --text-14: 0.875rem;
  --text-17: 1.0625rem;
  --text-22: 1.375rem;
  --text-28: 1.75rem;
  --text-34: 2.125rem;
  --text-44: 2.75rem;
  --text-display: clamp(2.5rem, 1.5rem + 3.4vw, 4rem);
  --leading-body: 1.6;
  --leading-heading: 1.15;

  /* Spacing */
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
  --space-48: 48px;
  --space-64: 64px;
  --section-gap: clamp(64px, 9vw, 112px);

  /* Shape and depth */
  --radius-button: 10px;
  --radius-card: 12px;
  --radius-panel: 20px;
  --radius-phone: 36px;
  --border-hairline: 1px;
  --border-focus: 3px;
  --elevation-1: 0 1px 2px rgb(var(--shadow-tint) / 0.08);
  --elevation-phone: 0 32px 64px -24px rgb(var(--shadow-tint) / 0.45), 0 8px 20px -8px rgb(var(--shadow-tint) / 0.25);

  /* Motion: colour changes and a small lift on hover; none when reduced */
  --motion-fast: 150ms;
  --motion-standard: 250ms;
  --motion-slow: 400ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --content-max: 1120px;
  --measure: 70ch;
  --target-min: 48px;

  color-scheme: light;
}

/* Dark: its own palette. Applied by the system setting, unless the reader
   chose Light with the toggle; or by the toggle itself. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #121d29;          /* midnight */
    --surface-alt: #1b2b3b;
    --on-surface: #f5f0e3;       /* warm ivory */
    --on-surface-muted: #bccbd6;
    --primary: #b8d4e8;          /* pale coastal blue */
    --primary-contrast: #121d29;
    --accent: #38382a;           /* dark lemon container */
    --accent-contrast: #ebdd9e;
    --sky: #263c51;
    --divider: #3a5066;
    --danger: #f2b8b5;
    --success: #a6d4a9;
    --photo-caption-bg: #1b2b3b;
    --link: #b8d4e8;
    --focus: #b8d4e8;
    --bezel: #0a121a;
    --shadow-tint: 0 0 0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --surface: #121d29;
  --surface-alt: #1b2b3b;
  --on-surface: #f5f0e3;
  --on-surface-muted: #bccbd6;
  --primary: #b8d4e8;
  --primary-contrast: #121d29;
  --accent: #38382a;
  --accent-contrast: #ebdd9e;
  --sky: #263c51;
  --divider: #3a5066;
  --danger: #f2b8b5;
  --success: #a6d4a9;
  --photo-caption-bg: #1b2b3b;
  --link: #b8d4e8;
  --focus: #b8d4e8;
  --bezel: #0a121a;
  --shadow-tint: 0 0 0;
  color-scheme: dark;
}

/* Screenshots exist in both themes: show the one matching the page. */
.only-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-dark { display: block !important; }
  :root:not([data-theme="light"]) .only-light { display: none !important; }
}
:root[data-theme="dark"] .only-dark { display: block !important; }
:root[data-theme="dark"] .only-light { display: none !important; }

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

html {
  -webkit-text-size-adjust: 100%;
  /* The sticky header must never cover an anchor target or a focused element. */
  scroll-padding-top: 80px;
}
a, button, summary { touch-action: manipulation; -webkit-tap-highlight-color: rgb(var(--shadow-tint) / 0.12); }

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: var(--text-17);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: var(--leading-heading);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-16);
  text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 1.7rem + 2vw, var(--text-44)); }
h2 { font-size: clamp(var(--text-28), 1.5rem + 1vw, var(--text-34)); margin-top: var(--space-48); }
h3 { font-size: var(--text-22); margin-top: var(--space-32); }
p, ul, ol, table { margin: 0 0 var(--space-16); }
p { text-wrap: pretty; }

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: var(--border-focus) solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: var(--space-16);
  top: -100px;
  padding: var(--space-12) var(--space-16);
  background: var(--primary);
  color: var(--primary-contrast);
  z-index: 10;
}
.skip-link:focus { top: var(--space-8); }

.wrap {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-16);
}
.prose { max-width: var(--measure); }
.lead { font-size: var(--text-22); line-height: 1.45; color: var(--on-surface-muted); }

/* Header: sticky, minimal, slightly translucent over the page */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: var(--border-hairline) solid var(--divider);
}
@media (prefers-reduced-transparency: reduce) {
  .site-header { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: var(--space-8) var(--space-16);
  min-height: 64px;
  flex-wrap: wrap;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-12);
  min-height: var(--target-min);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-22);
  letter-spacing: -0.01em;
  color: var(--on-surface);
  text-decoration: none;
}
.site-header .wordmark { margin-right: auto; }
.wordmark img { width: 28px; height: 28px; border-radius: 7px; }
.site-nav ul {
  display: flex;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  padding: 0 var(--space-12);
  border-radius: var(--radius-button);
  color: var(--on-surface);
  text-decoration: none;
  transition: background-color var(--motion-fast);
}
.site-nav a:hover { background: var(--sky); }
.site-nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
}

.theme-toggle {
  min-height: var(--target-min);
  min-width: var(--target-min);
  padding: 0 var(--space-16);
  border: var(--border-hairline) solid var(--divider);
  border-radius: var(--radius-button);
  background: transparent;
  color: var(--on-surface);
  font: inherit;
  font-size: var(--text-14);
  cursor: pointer;
  transition: background-color var(--motion-fast), border-color var(--motion-fast);
}
.theme-toggle:hover { background: var(--sky); border-color: var(--on-surface-muted); }
.theme-toggle[hidden] { display: none; }

main { padding: var(--space-48) 0 var(--section-gap); }

/* Buttons: compact, outlined first; filled for the one main action */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 var(--space-24);
  border-radius: var(--radius-button);
  border: 2px solid var(--primary);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--motion-fast), color var(--motion-fast), transform var(--motion-fast) var(--ease), box-shadow var(--motion-fast);
}
.button-primary { background: var(--primary); color: var(--primary-contrast); box-shadow: 0 6px 16px -8px rgb(var(--shadow-tint) / 0.6); }
.button-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -10px rgb(var(--shadow-tint) / 0.7); }
.button-primary:active { transform: translateY(0) scale(0.98); }
.button-secondary { background: transparent; color: var(--primary); }
.button-secondary:hover { background: var(--sky); }
.button[aria-disabled="true"] {
  border-color: var(--divider);
  color: var(--on-surface-muted);
  background: transparent;
  cursor: default;
}
.actions { display: flex; flex-wrap: wrap; gap: var(--space-12); margin-top: var(--space-32); }
.small { font-size: var(--text-14); color: var(--on-surface-muted); }

/* Sections */
.section { margin-top: var(--section-gap); }
.section > h2:first-child { margin-top: 0; }
.section-lead { max-width: 58ch; color: var(--on-surface-muted); margin-bottom: var(--space-32); }

/* Phone frame around a real screenshot of the app */
.phone {
  margin: 0;
  border-radius: var(--radius-phone);
  border: 8px solid var(--bezel);
  background: var(--bezel);
  box-shadow: var(--elevation-phone);
  overflow: hidden;
}
.phone img { display: block; width: 100%; border-radius: calc(var(--radius-phone) - 8px); }

/* Landing: hero */
.hero {
  display: grid;
  gap: var(--space-48);
  align-items: center;
}
.hero h1 { font-size: var(--text-display); line-height: 1.05; letter-spacing: -0.02em; margin-bottom: var(--space-24); max-width: 13ch; }
.hero .lead { max-width: 30ch; margin: 0; }
.hero-visual {
  position: relative;
  height: 520px;
  border-radius: var(--radius-panel);
  background: var(--accent);
  overflow: hidden;
}
.hero-visual .phone { position: absolute; width: 250px; }
.phone-front { left: 50%; top: 40px; transform: translateX(-50%); z-index: 1; }
.phone-back { display: none; }

/* Promises: one large tile with a screen, two small ones */
.bento { display: grid; gap: var(--space-16); }
.tile {
  border-radius: var(--radius-panel);
  background: var(--surface-alt);
  border: var(--border-hairline) solid var(--divider);
  padding: var(--space-32);
}
.tile h3 { margin-top: 0; font-size: var(--text-28); }
.tile p { margin: 0; color: var(--on-surface-muted); max-width: 46ch; }
.tile-strong { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.tile-strong p, .tile-strong a { color: var(--primary-contrast); }
.tile-feature {
  display: grid;
  gap: var(--space-32);
  background: var(--sky);
  border-color: var(--sky);
  padding-bottom: 0;
  overflow: hidden;
}
.tile-feature p { color: var(--on-surface); }
.tile-screen {
  justify-self: center;
  width: min(300px, 100%);
  height: 300px;
  overflow: hidden;
  border-radius: var(--radius-phone) var(--radius-phone) 0 0;
  border: 8px solid var(--bezel);
  border-bottom: 0;
  background: var(--bezel);
  box-shadow: var(--elevation-phone);
}
.tile-screen img { display: block; width: 100%; border-radius: calc(var(--radius-phone) - 8px) calc(var(--radius-phone) - 8px) 0 0; }

/* Regions: photos with their caption and credit underneath, never over */
.regions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-24) var(--space-16);
  grid-template-columns: 1fr 1fr;
}
.regions figure { margin: 0; display: flex; flex-direction: column; height: 100%; }
.regions img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-panel);
  background: var(--sky);
}
.regions figcaption { display: grid; gap: 2px; padding-top: var(--space-12); }
.region-name { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-22); line-height: 1.2; }
.region-towns { font-size: var(--text-14); font-weight: 600; color: var(--on-surface); }
.region-tagline { font-size: var(--text-14); color: var(--on-surface-muted); }
.credit { font-size: var(--text-12); color: var(--on-surface-muted); margin-top: var(--space-4); }
.credit a { color: inherit; }
.regions li:first-child { grid-column: 1 / -1; }
.regions li:first-child img { aspect-ratio: 16 / 9; }

/* A look inside: real screens, scroll sideways on a phone */
.screens {
  list-style: none;
  margin: 0;
  padding: var(--space-8) var(--space-16) var(--space-24);
  margin-inline: calc(-1 * var(--space-16));
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(72vw, 280px);
  gap: var(--space-24);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--space-16);
}
.screens li { scroll-snap-align: start; }
.screens figure { margin: 0; }
.screens figcaption { padding-top: var(--space-16); font-size: var(--text-14); color: var(--on-surface-muted); max-width: 30ch; }

.note {
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius-card);
  padding: var(--space-24);
}
.note a { color: inherit; }

/* FAQ: native disclosures, so it works with no JavaScript at all */
.faq-layout { display: grid; gap: var(--space-32); }
.faq-index ul { list-style: none; padding: 0; margin: 0; }
.faq-index a {
  display: flex;
  align-items: center;
  min-height: var(--target-min);
  padding: 0 var(--space-12);
  border-radius: var(--radius-button);
  color: var(--on-surface);
  text-decoration: none;
}
.faq-index a:hover { background: var(--sky); }
.faq-group { scroll-margin-top: 80px; }
.faq-group h2 {
  margin-top: var(--space-48);
  position: sticky;
  top: 64px;
  background: var(--surface);
  padding: var(--space-8) 0;
  z-index: 1;
  font-size: var(--text-28);
}
.faq-group:first-child h2 { margin-top: 0; }
details {
  background: var(--surface-alt);
  border: var(--border-hairline) solid var(--divider);
  border-radius: var(--radius-card);
  margin-bottom: var(--space-12);
  transition: border-color var(--motion-fast);
}
details:hover { border-color: var(--on-surface-muted); }
summary {
  display: flex;
  align-items: center;
  gap: var(--space-16);
  min-height: var(--target-min);
  padding: var(--space-16) var(--space-24);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "";
  flex: none;
  margin-left: auto;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-3px);
  transition: transform var(--motion-fast);
}
details[open] > summary::after { transform: rotate(-135deg) translateY(-3px); }
details > div { padding: 0 var(--space-24) var(--space-8); max-width: var(--measure); color: var(--on-surface-muted); }

/* Tables (sources, credits) */
.credits-group > .table-wrap { max-width: none; padding: 0; margin: 0 var(--space-16) var(--space-16); color: inherit; }
.credits-group summary { font-family: var(--font-heading); font-size: var(--text-22); }
.table-wrap {
  overflow-x: auto;
  border: var(--border-hairline) solid var(--divider);
  border-radius: var(--radius-card);
  background: var(--surface-alt);
  margin-bottom: var(--space-24);
}
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: var(--text-14); margin: 0; }
th, td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-12) var(--space-16);
  border-bottom: var(--border-hairline) solid var(--divider);
}
tbody tr:last-child td { border-bottom: 0; }
th { font-weight: 700; background: var(--accent); color: var(--accent-contrast); }
caption { text-align: left; color: var(--on-surface-muted); padding: var(--space-12) var(--space-16) 0; caption-side: top; }

.changelog { list-style: none; padding: 0; }
.changelog > li { border-left: 3px solid var(--primary); padding-left: var(--space-24); margin-bottom: var(--space-24); }
.changelog h3 { margin-top: 0; }

/* Footer */
.site-footer {
  border-top: var(--border-hairline) solid var(--divider);
  background: var(--surface-alt);
  padding: var(--space-48) 0 var(--space-32);
  font-size: var(--text-14);
  color: var(--on-surface-muted);
}
.footer-grid { display: grid; gap: var(--space-24); }
.footer-grid p { max-width: 44ch; margin: var(--space-8) 0 0; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-16); list-style: none; padding: 0; margin: 0; }
.site-footer nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  color: var(--on-surface);
  font-weight: 600;
}
.footer-meta { margin-top: var(--space-32); padding-top: var(--space-16); border-top: var(--border-hairline) solid var(--divider); }
.footer-meta p { margin: 0; }

/* Tablet: 8 columns */
@media (min-width: 600px) {
  .wrap { padding: 0 var(--space-32); }
  .screens { margin-inline: calc(-1 * var(--space-32)); padding-inline: var(--space-32); scroll-padding-inline: var(--space-32); }
  .regions { grid-template-columns: repeat(2, 1fr); }
  .hero-visual { height: 600px; }
  .hero-visual .phone { width: 280px; }
  .phone-front { left: 7%; transform: none; }
  .phone-back { display: block; right: 6%; top: 120px; width: 230px !important; transform: rotate(4deg); }
}
/* Desktop: 12 columns, 1120px content */
@media (min-width: 960px) {
  main { padding-top: var(--space-64); }
  .hero { grid-template-columns: 6fr 5fr; gap: var(--space-64); }
  .hero-visual { height: 620px; }
  .bento { grid-template-columns: 7fr 5fr; grid-template-rows: auto auto; }
  .tile-feature { grid-row: span 2; grid-template-rows: auto 1fr; }
  .tile-screen { height: 340px; align-self: end; }
  .regions { grid-template-columns: 2fr 1fr 1fr; }
  .regions li:first-child { grid-column: auto; grid-row: span 2; }
  .regions li:first-child img { aspect-ratio: auto; flex: 1; min-height: 0; }
  .screens {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
    overflow: visible;
    margin-inline: 0;
    padding: var(--space-48) 0 0;
    gap: var(--space-48);
  }
  .screens li:nth-child(2) { transform: translateY(calc(-1 * var(--space-48))); }
  .faq-layout { grid-template-columns: 3fr 9fr; }
  .faq-index { position: sticky; top: 80px; align-self: start; }
  .faq-group h2 { position: static; }
  .footer-grid { grid-template-columns: 1fr auto; align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
  .button-primary:hover { transform: none; }
}
