/* ─────────────────────────────────────────────────────────────────
   Sundial Simulator — style.css
   Visual metaphor: stone plaza at golden hour
   Primary: sandstone #E8DCC2, accent: terracotta #B55239
   ───────────────────────────────────────────────────────────────── */

/* Override --color-bg at :root so html element resolves to sandstone too —
   without this, html stays dark navy and shows on iOS rubber-band scroll.
   Body-scope override exists below but doesn't cascade to html.

   Then re-paint html with the chrome bg (#f0e6d4) so the iOS bottom
   rubber-band matches .site-footer instead of revealing the lighter
   sandstone body. Without this the diff was 12 RGB units — borderline
   but visible on overscroll. */
:root {
  --color-bg: #f5ede0;
}
html {
  background: #f0e6d4;
}

/* ── Page-level CSS custom properties ───────────────────────────── */
.sundial-sim-page {
  --sd-sand:         #E8DCC2;
  --sd-sand-dark:    #d4c8a8;
  --sd-sand-deeper:  #c4b492;
  --sd-terra:        #B55239;
  --sd-terra-light:  #c96a50;
  --sd-terra-dim:    rgba(181, 82, 57, 0.16);
  --sd-ink:          #3a2e22;
  --sd-ink-muted:    #6b5c48;
  --sd-ink-faint:    #9c8a72;
  --sd-radius:       12px;
  --sd-radius-sm:    7px;
  --sd-dial-size:    min(460px, calc(100vw - 48px));

  /* Shared token overrides for light surface */
  --color-bg: #f5ede0;
  --color-surface: #f0e6d4;
  --color-surface-2: #E8DCC2;
  --color-text: #3a2e22;
  --color-text-muted: #6b5c48;
  --color-border: rgba(100, 80, 60, 0.28);
}

/* ── Page shell ─────────────────────────────────────────────────── */
.sundial-sim-page .page-shell--tool {
  background: #f5ede0;
}

.sundial-sim-page .site-header {
  background: #f0e6d4;
  border-bottom: 1px solid var(--sd-sand-dark);
}

.sundial-sim-page .site-brand {
  color: var(--sd-ink);
}

.sundial-sim-page .tool-frame {
  position: relative;
}

/* ── Language toggle ─────────────────────────────────────────────── */
.sd-lang-toggle {
  position: absolute;
  top: 0;
  right: 0;
  padding: 5px 14px;
  min-height: 34px;
  background: var(--sd-sand);
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: 99px;
  color: var(--sd-ink-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
  z-index: 10;
  line-height: 1;
}
.sd-lang-toggle:hover {
  background: var(--sd-sand-dark);
  color: var(--sd-ink);
}

/* ── Tool header ─────────────────────────────────────────────────── */
.sundial-sim-page .page-title {
  color: var(--sd-ink);
  font-size: clamp(26px, 5vw, 38px);
}
.sundial-sim-page .page-subtitle {
  color: var(--sd-ink-muted);
  font-size: 15px;
}

/* ── Tool UI shell ───────────────────────────────────────────────── */
.sd-ui {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Desktop/default order: controls → stage → legend → data readout.
   Mobile (≤480px) swaps to: stage → legend → controls → data readout so
   the visual (and its key) is above the fold on the first screen. */
.sd-controls { order: 1; }
.sd-stage    { order: 2; }
.sd-legend   { order: 3; }
.sd-time-row { order: 4; }

/* ── Controls strip ──────────────────────────────────────────────── */
.sd-controls {
  background: var(--sd-sand);
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: var(--sd-radius);
  padding: 16px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sd-control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sd-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--sd-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.sd-lat-value {
  font-variant-numeric: tabular-nums;
  color: var(--sd-terra);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

/* Latitude slider */
.sd-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: linear-gradient(to right,
    var(--sd-terra) var(--sd-pct, 63.9%),
    var(--sd-sand-deeper) var(--sd-pct, 63.9%));
  outline: none;
  cursor: pointer;
}
.sd-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sd-terra);
  border: 3px solid var(--sd-sand);
  box-shadow: 0 2px 7px rgba(0,0,0,0.2);
  cursor: grab;
  transition: transform 120ms ease;
}
.sd-slider::-webkit-slider-thumb:active { transform: scale(1.15); cursor: grabbing; }
.sd-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sd-terra);
  border: 3px solid var(--sd-sand);
  box-shadow: 0 2px 7px rgba(0,0,0,0.2);
  cursor: grab;
}

.sd-slider-marks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--sd-ink-faint);
  margin-top: 2px;
}

/* Date input */
.sd-date-input {
  padding: 8px 12px;
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: var(--sd-radius-sm);
  background: #faf5ec;
  color: var(--sd-ink);
  font-size: 15px;
  font-family: inherit;
  width: 180px;
  cursor: pointer;
  transition: border-color 160ms ease;
}
.sd-date-input:focus {
  outline: none;
  border-color: var(--sd-terra);
}

.sd-date-hint {
  font-size: 12px;
  color: var(--sd-terra);
  min-height: 16px;
}

/* Presets */
.sd-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sd-preset-btn {
  padding: 5px 13px;
  min-height: 34px;
  background: transparent;
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: 99px;
  color: var(--sd-ink-muted);
  font-size: 13px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: nowrap;
  line-height: 1;
}
.sd-preset-btn:hover,
.sd-preset-btn.is-active {
  background: var(--sd-terra-dim);
  border-color: var(--sd-terra);
  color: var(--sd-terra);
}

/* Toggles */
.sd-toggles {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.sd-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--sd-ink-muted);
  user-select: none;
  min-height: 44px;
}

.sd-toggle-label input[type="checkbox"] {
  display: none;
}

.sd-toggle-track {
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: 99px;
  background: var(--sd-sand-deeper);
  position: relative;
  transition: background 200ms ease;
  flex-shrink: 0;
}
.sd-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 200ms ease;
}
.sd-toggle-label input:checked + .sd-toggle-track {
  background: var(--sd-terra);
}
.sd-toggle-label input:checked + .sd-toggle-track::after {
  transform: translateX(18px);
}

/* ── Dial stage ───────────────────────────────────────────────────── */
.sd-stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

#sd-canvas {
  display: block;
  width: var(--sd-dial-size);
  height: var(--sd-dial-size);
  border-radius: var(--sd-radius);
  touch-action: none;
}

/* Equation-of-time corner dial */
.sd-eot-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(240, 230, 212, 0.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: 10px;
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 82px;
}

#sd-eot-canvas {
  display: block;
  width: 60px;
  height: 60px;
}

.sd-eot-label {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--sd-terra);
}

.sd-eot-desc {
  font-size: 10px;
  color: var(--sd-ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Sun status overlay */
.sd-sun-status {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(240, 230, 212, 0.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: 99px;
  padding: 5px 16px;
  font-size: 12px;
  color: var(--sd-ink-muted);
  white-space: nowrap;
  pointer-events: none;
  /* hidden+display pattern per CLAUDE.md */
  display: none;
}
.sd-sun-status:not([hidden]):not(:empty) {
  display: block;
}

/* ── Canvas legend ──────────────────────────────────────────────── */
.sd-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 18px;
  padding: 10px 14px;
  background: var(--sd-sand);
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: var(--sd-radius-sm);
  font-size: 12.5px;
  color: var(--sd-ink-muted);
  line-height: 1.2;
}

.sd-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sd-legend-swatch {
  display: inline-block;
  flex-shrink: 0;
}

.sd-legend-swatch--sun {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #f5a623;
  border: 1.5px solid #e8901a;
}

.sd-legend-swatch--shadow {
  width: 22px;
  height: 6px;
  border-radius: 2px;
  background: linear-gradient(to right, rgba(25, 18, 10, 0.78), rgba(80, 60, 42, 0.14));
}

.sd-legend-swatch--arc {
  width: 22px;
  height: 0;
  border-top: 2.5px solid rgba(58, 46, 34, 0.85);
}

.sd-legend-swatch--beam {
  width: 22px;
  height: 0;
  border-top: 1.75px dashed rgba(245, 180, 70, 0.9);
}

@media (max-width: 480px) {
  .sd-legend {
    gap: 8px 14px;
    padding: 8px 10px;
    font-size: 11.5px;
  }
  .sd-legend-swatch--shadow,
  .sd-legend-swatch--arc,
  .sd-legend-swatch--beam { width: 18px; }
}

/* ── Time / data row ─────────────────────────────────────────────── */
.sd-time-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--sd-sand);
  border: 1.5px solid var(--sd-sand-deeper);
  border-radius: var(--sd-radius);
  padding: 12px 20px;
  flex-wrap: wrap;
}

.sd-time-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 80px;
}

.sd-time-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sd-ink-faint);
}

.sd-time-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--sd-ink);
  letter-spacing: -0.01em;
}

.sd-time-sep {
  color: var(--sd-sand-deeper);
  font-size: 22px;
  line-height: 1;
  align-self: center;
}

/* ── Notes ───────────────────────────────────────────────────────── */
.sd-notes {
  background: var(--sd-sand);
  border: 1.5px solid var(--sd-sand-deeper);
  border-left: 4px solid var(--sd-terra);
  border-radius: var(--sd-radius);
  padding: 20px 24px;
}

/* Override shared .tool-notes card styles */
.sundial-sim-page .tool-notes.sd-notes {
  background: var(--sd-sand);
  border: 1.5px solid var(--sd-sand-deeper);
  border-left: 4px solid var(--sd-terra);
}

.sd-notes-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--sd-ink);
  margin: 0 0 10px;
}

.sd-notes-text {
  font-size: 14px;
  line-height: 1.75;
  color: var(--sd-ink-muted);
  margin: 0 0 10px;
}
.sd-notes-text:last-child { margin-bottom: 0; }
.sd-notes-text strong { color: var(--sd-ink); }

/* ── Footer ──────────────────────────────────────────────────────── */
.sundial-sim-page .site-footer {
  background: #f0e6d4;
  border-top: 1px solid var(--sd-sand-dark);
  color: var(--sd-ink-muted);
}
.sundial-sim-page .site-footer a { color: var(--sd-ink-muted); }
.sundial-sim-page .site-footer a:hover { color: var(--sd-terra); }
.sundial-sim-page .footer-title { color: var(--sd-ink); }
.sundial-sim-page .footer-copy { color: var(--sd-ink-faint); }
.sundial-sim-page .footer-kofi-button {
  border-color: var(--sd-sand-deeper);
  color: var(--sd-ink-muted);
  background: transparent;
}
.sundial-sim-page .footer-kofi-button:hover {
  border-color: var(--sd-terra);
  color: var(--sd-terra);
  background: var(--sd-terra-dim);
}

/* ── Discovery section overrides ─────────────────────────────────── */
.sundial-sim-page .tool-discovery {
  --card-accent: var(--sd-terra);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .sundial-sim-page {
    --sd-dial-size: calc(100vw - 32px);
  }

  .sd-controls {
    padding: 12px 14px;
  }

  .sd-time-row {
    gap: 6px;
    padding: 10px 14px;
  }

  .sd-time-block {
    min-width: 68px;
  }

  .sd-time-value {
    font-size: 16px;
  }

  .sd-notes {
    padding: 16px;
  }

  .sd-eot-badge {
    bottom: 8px;
    right: 8px;
  }
}

@media (max-width: 480px) {
  /* Corner-pill lang toggle stays at top-right (was accidentally going
     full-width because of an earlier `position: static` override). */
  .sd-lang-toggle {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 4px 10px;
    min-height: 30px;
    font-size: 12px;
  }

  /* Stage-first ordering: visual dial BEFORE controls on small screens,
     so the first screenful shows what the tool does. */
  .sd-stage    { order: 1; }
  .sd-controls { order: 2; }
  .sd-time-row { order: 3; }

  /* EoT badge moves below the dial on mobile instead of overlapping the
     shadow-tip region — designer flagged 23%×32% occlusion in the bottom-
     right quadrant (exactly where high-latitude winter shadows land). */
  .sd-stage {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  .sd-eot-badge {
    position: static;
    flex-direction: row;
    gap: 8px;
    padding: 6px 10px;
    min-width: 0;
  }
  .sd-eot-badge #sd-eot-canvas {
    width: 44px;
    height: 44px;
  }
  .sd-eot-desc { font-size: 11px; }

  .sd-time-row {
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
  }

  .sd-time-sep {
    display: none;
  }

  .sd-time-block {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
  }

  .sd-presets {
    gap: 6px;
  }

  .sd-preset-btn {
    font-size: 12px;
    padding: 5px 10px;
  }
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sd-slider,
  .sd-toggle-track,
  .sd-toggle-track::after,
  .sd-preset-btn,
  .sd-lang-toggle {
    transition: none;
  }
}
