/* ── Custom properties ─────────────────────────────────────────────────────── */
:root {
  /* Background & surface */
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface-2:  #22263a;
  --text:       #e8eaf0;
  --text-muted: #8a8fa8;
  --border:     #2a2f48;
  --accent:     #4a9de0;

  /* Tone accent colours — override here for a design refresh */
  --c-warm:  #e8973a;
  --c-mild:  #3dab8a;
  --c-ideal: #4a9de0;
  --c-cold:  #7fafd4;
  --c-hot:   #e05a3a;

  /* Card tone backgrounds (precomputed dark tints) */
  --bg-warm:         #1e1a12;
  --bg-mild:         #111d1b;
  --bg-ideal:        #111720;
  --bg-cold:         #121820;
  --bg-warning-hot:  #1e1210;
  --bg-warning-cold: #101520;

  /* Layout */
  --r:   16px;
  --r-s: 10px;
  --sp:  clamp(16px, 4vw, 24px);
  --max: 480px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Ensure [hidden] always wins over explicit display rules on elements like .card-warning-flag */
[hidden] { display: none !important; }

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

/* ── Body ──────────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
  /* Safe-area padding for iPhone notch / home bar */
  padding-top:    max(var(--sp), env(safe-area-inset-top));
  padding-right:  max(var(--sp), env(safe-area-inset-right));
  padding-bottom: max(calc(var(--sp) * 2), env(safe-area-inset-bottom));
  padding-left:   max(var(--sp), env(safe-area-inset-left));
}

/* ── App wrapper ───────────────────────────────────────────────────────────── */
.app {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp);
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  text-align: center;
  padding-top: 4px;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Temperature section ───────────────────────────────────────────────────── */
.temp-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.temp-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.temp-control {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Stepper buttons — large touch targets */
.stepper {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.stepper:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stepper:disabled {
  opacity: 0.3;
  cursor: default;
}

.stepper:disabled:active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* Temperature display */
.temp-display {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 110px;
  justify-content: center;
}

.temp-num {
  font-size: 3.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.temp-unit {
  font-size: 1.5rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Slider ────────────────────────────────────────────────────────────────── */
.slider-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--bg);
  box-sizing: border-box;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 2px;
}

/* ── Result card ───────────────────────────────────────────────────────────── */
#result {
  min-height: 168px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-left-color: var(--border);
  border-radius: var(--r);
  padding: var(--sp);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-left-color 0.3s ease, background-color 0.3s ease;
}

/* Tone variants */
.card[data-tone="warm"]         { border-left-color: var(--c-warm);  background-color: var(--bg-warm); }
.card[data-tone="mild"]         { border-left-color: var(--c-mild);  background-color: var(--bg-mild); }
.card[data-tone="ideal"]        { border-left-color: var(--c-ideal); background-color: var(--bg-ideal); }
.card[data-tone="cold"]         { border-left-color: var(--c-cold);  background-color: var(--bg-cold); }
.card[data-tone="warning-hot"]  { border-left-color: var(--c-hot);   background-color: var(--bg-warning-hot); }
.card[data-tone="warning-cold"] { border-left-color: var(--c-cold);  background-color: var(--bg-warning-cold); }

/* Card header row: band + ltd label */
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.card-band {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.card-ltd {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-muted);
}

/* Warning flag (edge-case only) */
.card-warning-flag {
  display: inline-flex;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface-2);
}

.card[data-tone="warning-hot"]  .card-warning-flag { color: var(--c-hot); }
.card[data-tone="warning-cold"] .card-warning-flag { color: var(--c-cold); }

/* Main TOG number */
.card-tog {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* Clothing guidance */
.card-clothing {
  font-size: 1rem;
  line-height: 1.55;
}

/* Secondary note */
.card-note {
  font-size: 0.825rem;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* ── Collapsible (details/summary) ─────────────────────────────────────────── */
.collapsible {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.collapsible-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--sp);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.collapsible-summary::-webkit-details-marker { display: none; }

.collapsible-summary::after {
  content: '+';
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-muted);
}

details[open] > .collapsible-summary::after {
  content: '\2212'; /* minus sign */
}

.collapsible-body {
  padding: 0 var(--sp) var(--sp);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Size table ────────────────────────────────────────────────────────────── */
.size-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.size-table th,
.size-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.size-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.size-row-current td {
  color: var(--accent);
}

.size-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Safety list ───────────────────────────────────────────────────────────── */
.safety-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.safety-list li {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 16px;
  position: relative;
}

.safety-list li::before {
  content: '\00B7'; /* middle dot */
  position: absolute;
  left: 2px;
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 0.85;
}
