/*
  The look every page shares: colours, fonts, the header, the footer, buttons, labels,
  cards and form fields. Plain CSS with no build step. Every page gets it through
  layouts/site.blade.php, and each demo adds its own on top: mash.css (Country Mash),
  mapmaster.css (MapMaster), movie.css (AI Cinema), or a <style> in the page.

  The idea is a modern atlas: cool paper, deep ink, one warm colour for actions, a serif
  for names and headings and a monospace for the labels on the data.

  Light and dark are both here. The layout puts data-theme on <html> before the page
  draws: the visitor's own choice if they made one, and otherwise their device's setting.
*/

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }

:root {
  color-scheme: light;

  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #edf1f5;
  --line: #e0e6ed;
  --line-strong: #c6d0dc;
  --ink: #0e1b2b;
  --ink-2: #45566a;
  --ink-3: #66768a;
  --accent: #df4f29;
  --accent-hover: #c5421f;
  --accent-ink: #ffffff;
  --accent-soft: #fdece6;
  --ok: #17834a;
  --ok-soft: #e4f4ea;
  --warn: #a8660a;
  --danger: #c5362c;
  --danger-soft: #fdecea;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(14, 27, 43, .05), 0 10px 30px rgba(14, 27, 43, .07);
  --shadow-lg: 0 4px 10px rgba(14, 27, 43, .08), 0 24px 60px rgba(14, 27, 43, .18);

  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --header-h: 60px;

  /* How far the header and footer sit from the sides. A page whose content is one
     centred column sets "is-column" on <body>, and they line up with it. */
  --frame: 100%;
  --gutter: clamp(14px, 3vw, 28px);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #09101b;
  --surface: #101a29;
  --surface-2: #172335;
  --line: #1f2d43;
  --line-strong: #2e4160;
  --ink: #eaf0f8;
  --ink-2: #a9b8cb;
  --ink-3: #8697ad;
  --accent: #ff6c45;
  --accent-hover: #ff8766;
  --accent-ink: #1c0b05;
  --accent-soft: rgba(255, 108, 69, .14);
  --ok: #4fd08c;
  --ok-soft: rgba(79, 208, 140, .14);
  --warn: #f0b429;
  --danger: #ff7b70;
  --danger-soft: rgba(255, 123, 112, .14);

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 4px 10px rgba(0, 0, 0, .4), 0 24px 60px rgba(0, 0, 0, .6);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
body.is-column { --frame: 1120px; --gutter: clamp(20px, 4vw, 40px); }

a { color: var(--accent); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 40px);
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding-inline: max(var(--gutter), calc(50% - var(--frame) / 2 + var(--gutter)));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
  color: var(--ink);
  font: 600 1.15rem/1 var(--serif);
  letter-spacing: -.01em;
  text-decoration: none;
}
.brand-mark { flex-shrink: 0; color: var(--accent); }
.crumb { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--ink-3); font-size: .9rem; }
.crumb::before { content: '/'; color: var(--line-strong); }
.crumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-end { display: flex; align-items: center; flex-shrink: 0; gap: 8px; margin-left: auto; }
.header-meta { color: var(--ink-3); font: 500 .7rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.icon-btn, .header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font: 500 .85rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.icon-btn { width: 38px; padding: 0; }
.header-link { padding: 0 12px; }
.icon-btn:hover, .header-link:hover { border-color: var(--line-strong); color: var(--ink); }
@media (max-width: 420px) {
  /* Too little room left for the page's name to say anything. */
  .crumb { display: none; }
}
@media (max-width: 640px) {
  .header-meta { display: none; }
  .header-link span { display: none; }
  .header-link { width: 38px; padding: 0; }
}

/* The light and dark switch shows the look that is on: a sun or a moon. */
[data-theme-toggle] .moon, [data-theme-toggle] .when-dark { display: none; }
html[data-theme="dark"] [data-theme-toggle] .sun, html[data-theme="dark"] [data-theme-toggle] .when-light { display: none; }
html[data-theme="dark"] [data-theme-toggle] .moon { display: block; }
html[data-theme="dark"] [data-theme-toggle] .when-dark { display: inline; }

/* ── Footer ─────────────────────────────────────────────── */
.site-main { flex: 1; }
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: clamp(40px, 6vw, 72px);
  padding: 16px max(var(--gutter), calc(50% - var(--frame) / 2 + var(--gutter)));
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: .85rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 20px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 36px; color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font: 500 .85rem/1 var(--sans);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.theme-switch:hover { border-color: var(--line-strong); color: var(--ink); }

/* The buttons that close a page, such as "make another" and "back". */
.page-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: clamp(32px, 5vw, 52px); }
@media (max-width: 520px) {
  .page-actions .btn { flex: 1 1 100%; }
}

/* A short closing note above the footer, such as a credit. */
.page-note { max-width: 62ch; margin: clamp(28px, 4vw, 44px) auto 0; padding-inline: 16px; color: var(--ink-3); font-size: .8rem; line-height: 1.6; text-align: center; text-wrap: balance; }
.page-note a { color: inherit; }

/* ── Text ───────────────────────────────────────────────── */
.label {
  color: var(--ink-3);
  font: 500 .7rem/1.2 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.label.is-accent { color: var(--accent); }

/* A page's main heading: the serif, with one word picked out. */
.display { font: 600 clamp(2.2rem, 4.2vw, 3.1rem)/1.02 var(--serif); letter-spacing: -.03em; text-wrap: balance; }
.display em { color: var(--accent); font-style: italic; }
.lede { color: var(--ink-2); font-size: 1rem; line-height: 1.6; text-wrap: pretty; }
@media (max-width: 600px) {
  .display { font-size: clamp(2rem, 9.6vw, 2.6rem); }
}

/* A small label with a line running off to the right, above a part of the page. */
.divider { display: flex; align-items: center; gap: 14px; margin: clamp(28px, 4vw, 40px) 0 18px; }
.divider:first-child { margin-top: 0; }
.divider::after { content: ''; flex: 1; order: 1; height: 1px; background: var(--line); }
/* A second piece, such as a link, goes after the line. */
.divider > :nth-child(2) { order: 2; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: 600 .95rem/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); }
.btn-small { min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm); font-size: .875rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled { opacity: .45; pointer-events: none; }

/* ── Cards and small pieces ─────────────────────────────── */
.card {
  padding: clamp(18px, 2.4vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tag {
  display: inline-block;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: 500 .7rem/1.3 var(--mono);
  letter-spacing: .01em;
  white-space: nowrap;
}

.spinner {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner.is-small { width: 22px; height: 22px; border-width: 2.5px; }
.spinner.is-tiny { width: 16px; height: 16px; border-width: 2px; }
/* Inside a button it takes the button's own text colour. */
.btn .spinner { border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Google's "I'm not a robot" box is 304px wide and can't be resized, only scaled. On a
   narrow phone it is scaled down to the width of the fields around it. */
.captcha { display: flex; justify-content: center; min-height: 78px; }
@media (max-width: 399.98px) {
  .captcha { transform: scale(.94); }
}
@media (max-width: 353.98px) {
  .captcha { transform: scale(.82); }
}

/* ── Form fields ────────────────────────────────────────── */
.field-label { display: block; margin-bottom: 8px; }
.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  /* 16px keeps phones from zooming in when a field is tapped. */
  font: 400 1rem/1.4 var(--sans);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: .8; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 124px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
.select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%237b8a9c' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
.select option { background: var(--surface); color: var(--ink); }
.input.is-invalid, .textarea.is-invalid, .select.is-invalid { border-color: var(--danger); }
.field-hint { margin-top: 6px; color: var(--ink-3); font-size: .8rem; }
.field-error { display: none; margin-top: 6px; color: var(--danger); font-size: .82rem; }
.field-error.show { display: block; }

.alert { padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: .9rem; }

/* A short message that slides up from the bottom and leaves by itself. */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 2200;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: 500 .85rem/1.3 var(--sans);
  opacity: 0;
  transform: translateX(-50%) translateY(80px);
  transition: transform .3s var(--ease), opacity .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Text pages, such as Privacy ────────────────────────── */
.prose { max-width: 680px; padding-block: clamp(40px, 7vw, 80px) 0; }
.prose h1 { margin: 14px 0 8px; font: 600 clamp(2.2rem, 5vw, 3rem)/1.05 var(--serif); letter-spacing: -.03em; }
.prose h2 { margin: 36px 0 10px; font: 600 1.35rem/1.25 var(--serif); letter-spacing: -.01em; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 10px; }
.prose li strong { color: var(--ink); font-weight: 600; }
.prose code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font: 500 .85em var(--mono);
}

/* ── The analytics question (partials/analytics.blade.php) ── */
.consent {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 2147483000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  max-width: 580px;
  margin-inline: auto;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  font-size: .875rem;
  line-height: 1.45;
}
.consent-text { flex: 1 1 240px; }
.consent-text a { color: inherit; }
.consent .btn { min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm); font-size: .875rem; }

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