/* Base styles and components. Every value comes from tokens.css (generated from design/tokens/tokens.json).
   Mobile first: the defaults are the phone values; tokens.css switches border, radius, shadow and spacing at 768px. */

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

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

body {
  margin: 0;
  padding: var(--layout-page-padding);
  background: var(--color-surface-page);
  color: var(--color-text-primary);
  font-family: var(--type-body-family);
  font-weight: var(--type-body-weight);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line-height);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

.page { max-width: var(--layout-container); margin-inline: auto; }

/* Type roles */
h1, h2, h3, h4 { margin: 0 0 var(--space-4); text-wrap: balance; }
h1 { font: var(--type-h1-weight) var(--type-h1-size)/var(--type-h1-line-height) var(--type-h1-family); letter-spacing: var(--type-h1-letter-spacing); }
h2 { font: var(--type-h2-weight) var(--type-h2-size)/var(--type-h2-line-height) var(--type-h2-family); letter-spacing: var(--type-h2-letter-spacing); }
h3 { font: var(--type-h3-weight) var(--type-h3-size)/var(--type-h3-line-height) var(--type-h3-family); letter-spacing: var(--type-h3-letter-spacing); }
h4 { font: var(--type-h4-weight) var(--type-h4-size)/var(--type-h4-line-height) var(--type-h4-family); letter-spacing: var(--type-h4-letter-spacing); }

p { margin: 0 0 var(--space-4); max-width: var(--type-measure-body); text-wrap: pretty; }
.lead { font: var(--type-lead-weight) var(--type-lead-size)/var(--type-lead-line-height) var(--type-lead-family); }
.small { font: var(--type-small-weight) var(--type-small-size)/var(--type-small-line-height) var(--type-small-family); }
strong, .strong { font-weight: var(--type-body-strong-weight); }
.muted { color: var(--color-text-muted); }

a { color: inherit; text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 0.1em; }

/* Keyboard focus: visible against the thick border thanks to the offset gap */
:focus-visible { outline: var(--focus-ring); outline-offset: 4px; }

/* Surfaces: card (white) and block (sand) share one recipe */
.card, .block {
  border: var(--component-card-border);
  border-radius: var(--component-card-radius);
  box-shadow: var(--component-card-shadow);
  padding: var(--space-4);
  background: var(--component-card-background);
}
.block { background: var(--component-block-background); }
@media (min-width: 768px) { .card, .block { padding: var(--space-8); } }

/* Button: >= 48px tall, label role, pressed feedback on every device, hover on pointer devices only */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--component-button-minHeight, 48px);
  min-width: var(--touch-target);
  padding: 0 var(--space-6);
  font: var(--type-label-weight) var(--type-label-size)/var(--type-label-line-height) var(--type-label-family);
  color: var(--color-text-primary);
  text-decoration: none;
  background: var(--component-button-background);
  border: var(--component-button-border);
  border-radius: var(--component-button-radius);
  box-shadow: var(--component-button-shadow);
  cursor: pointer;
  transition: transform var(--interaction-duration) ease-out, box-shadow var(--interaction-duration) ease-out;
}
.btn--sand { background: var(--color-surface-sand); }
@media (hover: hover) {
  .btn:hover {
    transform: translate(var(--interaction-hover-shift), var(--interaction-hover-shift));
    box-shadow: calc(var(--shadow-offset) - var(--interaction-hover-shift)) calc(var(--shadow-offset) - var(--interaction-hover-shift)) 0 0 var(--color-border-default);
  }
}
.btn:active { transform: translate(var(--shadow-offset), var(--shadow-offset)); box-shadow: 0 0 0 0 var(--color-border-default); }
.btn[disabled], .btn[aria-disabled="true"] { color: var(--color-text-muted); background: var(--color-black-100); box-shadow: none; transform: none; cursor: not-allowed; }

/* Form field: 16px label-role text so iOS does not zoom */
.input {
  width: 100%;
  min-height: var(--component-input-minHeight, 48px);
  padding: 0 var(--space-4);
  font: var(--type-label-weight) var(--type-label-size)/var(--type-label-line-height) var(--type-label-family);
  color: var(--color-text-primary);
  background: var(--component-input-background);
  border: var(--component-input-border);
  border-radius: var(--component-input-radius);
}

/* Status tag: accent fill, black text, black border; always carries a text label (and an icon where used) */
.tag { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 0 var(--space-3); font: var(--type-label-weight) var(--type-small-size)/1 var(--type-label-family); border: 3px solid var(--color-border-default); border-radius: 999px; }
.tag--error { background: var(--color-status-error); }
.tag--warning { background: var(--color-status-warning); }
.tag--success { background: var(--color-status-success); }

/* Icons: Lucide sprite (public/icons/sprite.svg). <svg class="icon" aria-hidden="true"><use href="/icons/sprite.svg#menu"></use></svg>
   Decorative icons get aria-hidden; an icon-only button needs an accessible name on the button (aria-label or visible text). */
.icon {
  width: var(--icon-size-md); height: var(--icon-size-md); flex: none;
  fill: none; stroke: currentColor; stroke-width: var(--icon-stroke-md);
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
}
.icon--sm { width: var(--icon-size-sm); height: var(--icon-size-sm); stroke-width: var(--icon-stroke-sm); }
.icon--lg { width: var(--icon-size-lg); height: var(--icon-size-lg); stroke-width: var(--icon-stroke-lg); }
.btn .icon { margin-inline: calc(var(--space-1) * -1) 0; }
.btn .icon + span, .btn span + .icon { margin-inline-start: var(--space-2); }
.btn--icon { padding: 0; width: var(--touch-target); }

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

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