/* Suits vs. Toons primitives. Built only from tokens.css; no raw colours or sizes here.
   Sections: base, layout, header, footer, wordmark and title lettering, buttons, links, plaque,
   badge, callout, form field, hero. See DESIGN.md for when to use each. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-body);
  line-height: var(--leading-body);
}

[data-theme] {
  background-color: var(--color-bg);
  color: var(--color-text);
}

main {
  flex: 1 0 auto;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400; /* Chewy has one weight; never fake-bold it */
  line-height: var(--leading-tight);
  letter-spacing: 0.01em;
  color: var(--color-text);
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}

h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }
h4 { font-size: var(--text-lg); }

p, ul, ol {
  margin: 0 0 var(--space-4);
}

ul, ol {
  padding-left: var(--space-6);
}

li + li {
  margin-top: var(--space-2);
}

strong, b {
  font-weight: var(--weight-strong);
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

::selection {
  background: var(--color-sun);
  color: var(--color-on-sun);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-24));
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border: var(--border-ink);
  border-radius: var(--radius-md);
  background: var(--color-sun);
  color: var(--color-on-sun);
  font-weight: var(--weight-ui);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-3);
}

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

.lede {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  color: var(--color-text-muted);
}

.muted {
  color: var(--color-text-muted);
}

/* ---- Layout */
.container {
  width: min(var(--container), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.container--prose {
  width: min(var(--container-prose), 100% - 2 * var(--gutter));
}

.section {
  padding-block: var(--space-12);
}

.section--tight {
  padding-block: var(--space-6);
}

/* Vertical rhythm for a run of blocks. */
.stack > * {
  margin-block: 0;
}

.stack > * + * {
  margin-top: var(--stack-gap, var(--space-4));
}

/* Long-form text (privacy, terms). */
.prose {
  max-width: var(--measure);
}

.prose h2 {
  margin-top: var(--space-10);
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

/* A responsive grid: columns at least --grid-min wide, one column on phones. The gap leaves room for rims. */
.grid {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min, 16rem)), 1fr));
}

/* A row of inline things that wraps. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-3));
}

/* ---- Header */
.site-header {
  --rim: var(--brand-sun);
  background: var(--color-surface);
  border-bottom: var(--border-ink);
  box-shadow: 0 var(--rim-width) 0 0 var(--rim);
  margin-bottom: var(--rim-width);
  position: relative;
  z-index: 1;
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  padding-block: var(--space-2);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav li + li {
  margin-top: 0;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding-inline: var(--space-4);
  border: var(--outline-width) solid transparent;
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-weight: var(--weight-ui);
  line-height: var(--leading-snug);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-bounce);
}

.site-nav a:hover {
  background: var(--color-surface-raised);
  border-color: var(--color-outline);
  transform: translateY(var(--lift));
}

.site-nav a[aria-current="page"] {
  background: var(--color-sun);
  border-color: var(--color-outline);
  color: var(--color-on-sun);
}

/* ---- Theme switch (header): Auto / Light / Dark, driven by js/theme.js */
.site-header__end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.site-header__inner--no-mark {
  justify-content: flex-end;
}

.theme-switch {
  display: flex;
  gap: var(--space-1);
}

.theme-switch button {
  min-height: var(--tap);
  padding-inline: var(--space-3);
  border: var(--outline-width) solid transparent;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-ui);
  cursor: pointer;
}

.theme-switch button:hover {
  background: var(--color-surface-raised);
  border-color: var(--color-outline);
}

.theme-switch button[aria-pressed="true"] {
  background: var(--color-surface-raised);
  border-color: var(--color-outline);
  color: var(--color-text);
}

/* ---- Footer */
.site-footer {
  --rim: var(--brand-sun);
  margin-top: var(--space-8);
  padding-block: var(--space-8) var(--space-10);
  background: var(--color-surface);
  border-top: var(--border-ink);
  box-shadow: 0 calc(-1 * var(--rim-width)) 0 0 var(--rim);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-6);
}

.site-footer a {
  color: var(--color-link);
}

.site-footer nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer nav li + li {
  margin-top: 0;
}

.site-footer nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: var(--weight-strong);
}

/* ---- Wordmark (SVG file, img/wordmark*.svg) */
.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  border-radius: var(--radius-md);
  transition: transform var(--dur-base) var(--ease-bounce);
}

.wordmark img {
  display: block;
  height: clamp(2.25rem, 1.8rem + 2vw, 3.25rem);
  width: auto;
}

a.wordmark:hover {
  transform: rotate(var(--wiggle)) scale(1.03);
}

.wordmark--hero img {
  height: auto;
  width: clamp(15rem, 10rem + 25vw, 28rem);
}

/* ---- Layered title lettering in live text: rim, ink outline, gradient fill.
   Markup: <h1 class="toon-title" data-text="Same text"><span>Same text</span></h1>
   The two pseudo-elements repeat data-text behind the span: the rim stroke first, the ink stroke on it,
   the gradient-filled span on top. Strokes are centred on the glyph edge, so only their outer half shows. */
.toon-title {
  position: relative;
  z-index: 0;
  isolation: isolate;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--toon-fill);
  padding-inline: 0.12em;
  margin-bottom: var(--space-4); /* room for the rim */
}

.toon-title > span {
  background-image: linear-gradient(to bottom, var(--toon-fill-top), var(--toon-fill));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.toon-title::before,
.toon-title::after {
  content: attr(data-text);
  content: attr(data-text) / "";
  position: absolute;
  inset: 0;
  z-index: -1;
  padding-inline: inherit;
  pointer-events: none;
}

.toon-title::before {
  color: var(--toon-rim);
  -webkit-text-stroke: 0.2em var(--toon-rim);
}

.toon-title::after {
  color: var(--toon-ink);
  -webkit-text-stroke: 0.09em var(--toon-ink);
}

/* ---- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: var(--space-2) var(--space-5);
  border: var(--border-ink);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  color: var(--color-text);
  box-shadow: var(--shadow-press);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-ui);
  line-height: var(--leading-snug);
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-bounce),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.btn:hover {
  transform: translateY(var(--lift));
  box-shadow: var(--shadow-press-up);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: var(--shadow-press-down);
}

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

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

.btn--secondary {
  background: var(--brand-teal);
  color: var(--brand-ink);
}

.btn--secondary:hover {
  background: var(--brand-cream);
}

.btn--ghost {
  background: transparent;
  border-color: var(--color-field-border);
  box-shadow: none;
}

.btn--ghost:hover {
  background: var(--color-surface-raised);
  box-shadow: none;
}

.btn--ghost:active {
  box-shadow: none;
}

.btn--lg {
  min-height: 3.5rem;
  padding-inline: var(--space-8);
  font-size: var(--text-lg);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--color-border);
  border-color: var(--color-border);
  color: var(--color-text-muted);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

/* ---- Links */
a {
  color: var(--color-link);
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--color-link-hover);
  text-decoration-thickness: 3px;
}

/* ---- Plaque (card / panel): fill, ink outline, coloured rim, cartoon drop shadow. */
.plaque {
  --rim: var(--brand-sun);
  position: relative;
  margin: var(--rim-width);
  padding: var(--space-6);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-plaque);
}

.plaque > :last-child {
  margin-bottom: 0;
}

.plaque__title {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 400;
  line-height: var(--leading-tight);
  margin: 0 0 var(--space-3);
}

.plaque--raised { background: var(--color-surface-raised); }
.plaque--orange { --rim: var(--brand-orange); }
.plaque--teal { --rim: var(--brand-teal); }
.plaque--dock { --rim: var(--brand-dock); }
.plaque--gardens { --rim: var(--brand-gardens); }
.plaque--dream { --rim: var(--brand-dream); }
.plaque--brrrgh { --rim: var(--brand-brrrgh-deep); }

@media (min-width: 40rem) {
  .plaque {
    padding: var(--space-8);
  }
}

/* ---- Badge / pill (not interactive) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: 2px solid var(--color-outline);
  border-radius: var(--radius-pill);
  background: var(--color-sun);
  color: var(--color-on-sun);
  font-size: var(--text-sm);
  font-weight: var(--weight-ui);
  line-height: var(--leading-snug);
  white-space: nowrap;
}

.badge--accent { background: var(--color-accent); color: var(--color-on-accent); }
.badge--teal { background: var(--brand-teal); color: var(--brand-ink); }
.badge--success { background: var(--color-success-bg); color: var(--color-success); border-color: currentColor; }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: currentColor; }
.badge--danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: currentColor; }
.badge--info { background: var(--color-info-bg); color: var(--color-info); border-color: currentColor; }

/* ---- Callout / notice. Variants set the tint and the edge; the text stays --color-text. */
.callout {
  --callout-bg: var(--color-surface-raised);
  --callout-edge: var(--color-field-border);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-4) var(--space-5);
  background: var(--callout-bg);
  color: var(--color-text);
  border: 2px solid var(--callout-edge);
  border-left-width: var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout__body > :last-child {
  margin-bottom: 0;
}

.callout__icon {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  margin-top: 0.1rem;
}

.callout__title {
  display: block;
  font-weight: var(--weight-ui);
  color: var(--callout-edge);
}

.callout--note { --callout-edge: var(--color-field-border); }
.callout--info { --callout-bg: var(--color-info-bg); --callout-edge: var(--color-info); }
.callout--success { --callout-bg: var(--color-success-bg); --callout-edge: var(--color-success); }
.callout--warning { --callout-bg: var(--color-warning-bg); --callout-edge: var(--color-warning); }
.callout--danger { --callout-bg: var(--color-danger-bg); --callout-edge: var(--color-danger); }

/* ---- Form field */
.field {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.field__label {
  font-weight: var(--weight-ui);
  line-height: var(--leading-snug);
}

.field__hint {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.field__error {
  color: var(--color-danger);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  line-height: var(--leading-snug);
}

.input {
  width: 100%;
  min-height: 3rem;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-raised);
  color: var(--color-text);
  border: var(--outline-width) solid var(--color-field-border);
  border-radius: var(--radius-md);
  font: inherit;
  line-height: var(--leading-snug);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.input:hover {
  box-shadow: 0 0 0 var(--space-1) var(--color-border);
}

.input:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
  box-shadow: none;
}

.input[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.input:disabled {
  background: var(--color-border);
  color: var(--color-text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* ---- Hero: sky gradient, hills along the bottom, spot art floating. */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: var(--space-10) 0;
  background: linear-gradient(to bottom, var(--color-sky-top), var(--color-sky-bottom));
  text-align: center;
}

.hero__inner {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
}

.hero h1 {
  margin: 0;
}

.hero .lede {
  max-width: 32rem;
  margin: 0;
  color: var(--color-text);
  font-weight: var(--weight-strong);
}

.hero__hills {
  position: relative;
  left: 50%;
  display: block;
  width: max(100%, 48rem);
  max-width: none;
  height: auto;
  margin-top: calc(-1 * var(--space-4));
  transform: translateX(-50%);
  filter: var(--art-filter);
}

.hero__art {
  position: absolute;
  z-index: 0;
  width: clamp(3.5rem, 2rem + 6vw, 7rem);
  height: auto;
  filter: var(--art-filter);
  transition: transform var(--dur-slow) var(--ease-bounce);
}

.hero__art--cog {
  left: max(var(--space-2), 50% - 26rem);
  top: var(--space-8);
  transform: rotate(-12deg);
}

.hero__art--pie {
  right: max(var(--space-2), 50% - 26rem);
  top: var(--space-16);
  transform: rotate(8deg);
}

@media (max-width: 34rem) {
  .hero__art--cog { top: var(--space-2); }
  .hero__art--pie { top: var(--space-2); }
}

/* Toggle buttons (aria-pressed): the pressed one reads as selected. */
.btn[aria-pressed="true"] {
  background: var(--color-sun);
  border-color: var(--color-outline);
  color: var(--color-on-sun);
}
