/* ============================================================================
 * ios-answer-tarot · Design System Tokens (tokens.css)
 * Foundation: Adobe Spectrum 2 + Telegram TG-Catalog (279f89e) + Emil Skills
 * Theme: Warm Parchment / Ivory Dawn (暖羊皮卷 · 清爽浅色模式 Default Light, locked)
 * 2026.11.12 Naron
 * ============================================================================ */

:root,
:root[data-theme="light"],
:root[data-theme="parchment"],
:root[data-theme="lavender"],
:root[data-theme="dark"],
:root[data-theme="obsidian"] {
  color-scheme: light;

  /* --- Core Canvas & Surface Hierarchy (Spectrum 2 Layered Light) --- */
  --bg-pasteboard: #EAE4DC;
  --bg-canvas: #FAF6EE;
  --bg-surface-1: #F2ECE1;
  --bg-surface-2: #E8DFD1;
  --bg-surface-3: #DDD2C0;
  --bg-elevated: #FFFFFF;
  --bg-glass: rgba(250, 246, 238, 0.90);
  --bg-sheet: #FCF9F4;
  --bg-scrim: rgba(30, 24, 16, 0.36);

  /* --- Typography & Ink Hierarchy (WCAG AA >= 4.5:1 verified) --- */
  --text-primary: #1E1B18;
  --text-secondary: #524A40;
  --text-muted: #6E6559;
  --text-on-accent: #FFFFFF;
  --text-on-mystic: #FFFFFF;

  /* --- Semantic Accents (Warm Amber Gold + Quin Lavender + Clean Tool) --- */
  --accent-gold: #9E7418;
  --accent-gold-hover: #876110;
  --accent-gold-soft: rgba(158, 116, 24, 0.12);
  --accent-gold-ring: rgba(158, 116, 24, 0.28);

  --accent-mystic: #5E43B0;
  --accent-mystic-soft: rgba(94, 67, 176, 0.12);
  --accent-mystic-border: rgba(94, 67, 176, 0.26);

  --accent-lavender-card: #EFEAF9;
  --accent-sage-card: #E6F1EC;
  --accent-amber-card: #F5EDD9;
  --accent-rose-card: #F7E8ED;

  --accent-success: #1E8A58;
  --accent-success-soft: rgba(30, 138, 88, 0.12);
  --accent-warning: #C4821A;
  --accent-danger: #C93B32;
  --accent-danger-soft: rgba(201, 59, 50, 0.11);

  /* --- Hairline Borders & Dividers (Craft-Floor: max 1px, never thick side-borders) --- */
  --border-hairline: rgba(158, 116, 24, 0.22);
  --border-subtle: rgba(30, 27, 24, 0.08);
  --border-strong: rgba(158, 116, 24, 0.38);
  --divider-line: rgba(30, 27, 24, 0.08);

  /* --- Shadows & Ambient Glow (Soft Warm Light Elevation) --- */
  --shadow-card: 0 6px 20px rgba(45, 36, 24, 0.07);
  --shadow-sheet: 0 -8px 28px rgba(30, 24, 16, 0.12);
  --shadow-gold-glow: 0 4px 14px rgba(158, 116, 24, 0.18);

  /* --- Card Deck Specific (Warm Ivory & Gilded Parchment Back) --- */
  --card-back-bg: #F3EAD8;
  --card-back-pattern: rgba(158, 116, 24, 0.48);
  --card-face-bg: #FFFDF9;
}

/* ============================================================================
 * Adobe Spectrum 2 Spatial, Typography & Motion Scales
 * ============================================================================ */
:root {
  /* Viewport Reference (iPhone 15 Pro 1:1 Logical Viewport) */
  --device-width: 393px;
  --device-height: 852px;
  --safe-top: 54px;
  --safe-bottom: 34px;
  --tabbar-height: 82px;

  /* Spectrum 2 Spacing Scale */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 20px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* Corner Radii (Aligned with Spectrum 2 & Telegram SheetComponent) */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-card: 16px;
  --radius-sheet: 20px;
  --radius-pill: 999px;

  /* Font Stacks (Zero Google Fonts network block) */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "New York", Georgia, serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, monospace;

  /* Spectrum 2 Type Scale (Baseline-aligned) */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 30px;

  /* Emil Kowalski & Telegram Spring / Easing Curves */
  --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================================================
 * Mobile-Native & Emil-Design-Eng Global Guardrails
 * ============================================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-pasteboard);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

/* Pressable feedback rule: every interactive control scales to 0.97 on active */
.pressable,
button,
[role="button"] {
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 140ms var(--ease-out-quart), background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.pressable:active,
button:active,
[role="button"]:active {
  transform: scale(0.97);
}

/* High-frequency TabBar switches have 0 animation */
.tabbar-item {
  transition: none !important;
}

/* Standard iPhone 15 Pro Artboard Shell (393x852pt) */
.artboard-shell {
  position: relative;
  width: var(--device-width);
  height: var(--device-height);
  background: var(--bg-canvas);
  color: var(--text-primary);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  outline: 1px solid var(--border-hairline);
}

/* iOS Status Bar + Dynamic Island */
.ios-statusbar {
  height: var(--safe-top);
  padding: 14px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
  flex-shrink: 0;
  z-index: 30;
  position: relative;
}

.dynamic-island {
  width: 120px;
  height: 34px;
  background: #000000;
  border-radius: 20px;
  position: absolute;
  left: 50%;
  top: 11px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
}

/* Telegram TG-03 Segmented Pill */
.tg-segmented-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tg-segmented-btn {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  line-height: 1.2;
  white-space: nowrap;
}

.tg-segmented-btn.is-active {
  background: var(--bg-surface-2);
  border-color: var(--border-strong);
  color: var(--accent-gold);
  font-weight: 600;
}

/* Telegram TG-01 Compact Sheet Grabber */
.tg-grabber {
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: var(--text-muted);
  opacity: 0.45;
  margin: 8px auto 6px;
}

/* Telegram TG-05 Floating Toast */
.tg-toast {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 96px;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  padding: 11px 14px;
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  z-index: 90;
  opacity: 0;
  transform: scale(0.95) translateY(8px);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out-quart), transform 220ms var(--ease-spring);
}

.tg-toast.is-visible {
  display: flex;
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Bottom 4-Tab Bar (SF Symbols 20x20pt Linear, 0ms switch) */
.ios-tabbar {
  height: var(--tabbar-height);
  padding: 8px 12px var(--safe-bottom);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: start;
  flex-shrink: 0;
  z-index: 40;
}

.ios-tab-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  padding: 2px 0;
  font-size: 11px;
  font-weight: 500;
}

.ios-tab-btn.is-active {
  color: var(--accent-gold);
  font-weight: 600;
}

.ios-tab-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
}
