/* 拾光票根 — Brand Design Tokens (shared) */
/* Primary: 浅蓝 #E6F2FF / 深蓝 #235796 / 纯白 #FFFFFF */

:root {
  /* Brand primary scale — single hue */
  --sg-blue-50: #F0F8FF;
  --sg-blue-100: #E6F2FF;
  --sg-blue-200: #CCE5FF;
  --sg-blue-300: #99CBFF;
  --sg-blue-400: #6B9CCF;
  --sg-blue-500: #4078B3;
  --sg-blue-600: #235796;
  --sg-blue-700: #1A4068;
  --sg-blue-800: #122A45;
  --sg-blue-900: #0A1624;

  /* Neutral scale */
  --sg-white: #FFFFFF;
  --sg-gray-50: #F8FAFC;
  --sg-gray-100: #F1F5F9;
  --sg-gray-200: #E2E8F0;
  --sg-gray-300: #CBD5E1;
  --sg-gray-400: #94A3B8;
  --sg-gray-500: #64748B;
  --sg-gray-600: #475569;
  --sg-gray-700: #334155;
  --sg-gray-800: #1E293B;
  --sg-gray-900: #0F172A;

  /* State colors */
  --sg-state-success: #10B981;
  --sg-state-warning: #F59E0B;
  --sg-state-error: #EF4444;
  --sg-state-info: #3B82F6;

  /* Default theme: 原版晴空蓝 */
  --sg-background: var(--sg-blue-100);
  --sg-foreground: var(--sg-blue-700);
  --sg-card: var(--sg-white);
  --sg-card-foreground: var(--sg-blue-700);
  --sg-popover: var(--sg-white);
  --sg-popover-foreground: var(--sg-blue-700);
  --sg-primary: var(--sg-blue-600);
  --sg-primary-light: var(--sg-blue-500);
  --sg-primary-foreground: var(--sg-white);
  --sg-muted: var(--sg-gray-50);
  --sg-muted-foreground: var(--sg-blue-400);
  --sg-border: var(--sg-blue-200);
  --sg-input: var(--sg-white);
  --sg-ring: var(--sg-blue-600);

  /* Radius scale — restrained */
  --sg-radius-small: 4px;
  --sg-radius-medium: 8px;
  --sg-radius-large: 12px;
  --sg-radius-full: 9999px;

  /* Shadows — floating layers only exceed 0.05 alpha */
  --sg-shadow-sm: 0 1px 2px rgba(26, 64, 104, 0.04);
  --sg-shadow-md: 0 4px 12px rgba(26, 64, 104, 0.05);
  --sg-shadow-lg: 0 12px 32px rgba(26, 64, 104, 0.05);
  --sg-shadow-inner: inset 0 1px 2px rgba(26, 64, 104, 0.04);

  /* Typography */
  --sg-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --sg-font-mono: "SF Mono", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;

  /* Spacing */
  --sg-safe-top: env(safe-area-inset-top, 0px);
  --sg-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Theme variations via data attribute */
[data-theme="qingkong"] {
  --sg-background: #E6F2FF;
  --sg-foreground: #235796;
  --sg-primary: #235796;
  --sg-primary-light: #3B82F6;
  --sg-muted-foreground: #6B9CCF;
  --sg-border: #CCE5FF;
}

[data-theme="wuyu"] {
  --sg-background: #EEF5FB;
  --sg-foreground: #36648B;
  --sg-primary: #36648B;
  --sg-primary-light: #5B9BD5;
  --sg-muted-foreground: #6B9CCF;
  --sg-border: #D6E4F0;
}

[data-theme="shenhai"] {
  --sg-background: #D6E4F0;
  --sg-foreground: #1A4068;
  --sg-primary: #1A4068;
  --sg-primary-light: #2C5282;
  --sg-muted-foreground: #2C5282;
  --sg-border: #B8D0E8;
}

[data-theme="qingyang"] {
  --sg-background: #F0F8FF;
  --sg-foreground: #4078B3;
  --sg-primary: #4078B3;
  --sg-primary-light: #5B9BD5;
  --sg-muted-foreground: #6B9CCF;
  --sg-border: #D6E8FA;
}

[data-theme="xingye"] {
  --sg-background: #E8F4FF;
  --sg-foreground: #285E9E;
  --sg-primary: #285E9E;
  --sg-primary-light: #3B82F6;
  --sg-muted-foreground: #6B9CCF;
  --sg-border: #C2DDF7;
}

/* 琥珀纸语 — 纸感底色 + 墨棕文字 + 琥珀主色 */
[data-theme="hupo"] {
  --sg-background: #F5EFE6;
  --sg-foreground: #2D1B12;
  --sg-card: #FFFBF3;
  --sg-card-foreground: #2D1B12;
  --sg-popover: #FFFBF3;
  --sg-popover-foreground: #2D1B12;
  --sg-primary: #C8855A;
  --sg-primary-light: #D4A574;
  --sg-primary-foreground: #F5EFE6;
  --sg-muted: #EDE3D2;
  --sg-muted-foreground: #A0683E;
  --sg-border: #E0D2BD;
  --sg-input: #FFFBF3;
  --sg-ring: #C8855A;
  --sg-accent-gold: #D4A857;
  --sg-accent-seal: #C44536;
  --sg-accent-forest: #4A6741;
  --sg-accent-pine: #3A6B6E;
  --sg-shadow-sm: 0 1px 2px rgba(45, 27, 18, 0.05);
  --sg-shadow-md: 0 4px 12px rgba(45, 27, 18, 0.06);
  --sg-shadow-lg: 0 12px 32px rgba(45, 27, 18, 0.08);
}

.sg-swatch-hupo {
  background: linear-gradient(135deg, #F5EFE6 0%, #C8855A 100%);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) {
    --sg-background: #0F172A;
    --sg-foreground: #E6F2FF;
    --sg-card: #1E293B;
    --sg-card-foreground: #E6F2FF;
    --sg-popover: #1E293B;
    --sg-popover-foreground: #E6F2FF;
    --sg-primary: #6B9CCF;
    --sg-primary-light: #93C5FD;
    --sg-primary-foreground: #0F172A;
    --sg-muted: #172554;
    --sg-muted-foreground: #94A3B8;
    --sg-border: #334155;
    --sg-input: #1E293B;
    --sg-ring: #6B9CCF;
    --sg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --sg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --sg-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.05);
  }
}

[data-color-scheme="dark"] {
  --sg-background: #0F172A;
  --sg-foreground: #E6F2FF;
  --sg-card: #1E293B;
  --sg-card-foreground: #E6F2FF;
  --sg-popover: #1E293B;
  --sg-popover-foreground: #E6F2FF;
  --sg-primary: #6B9CCF;
  --sg-primary-light: #93C5FD;
  --sg-primary-foreground: #0F172A;
  --sg-muted: #172554;
  --sg-muted-foreground: #94A3B8;
  --sg-border: #334155;
  --sg-input: #1E293B;
  --sg-ring: #6B9CCF;
  --sg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --sg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --sg-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.05);
}

/* NOTE: a [data-color-scheme="light"] override is intentionally omitted.
   The :not([data-color-scheme="light"]) guard on the dark-media block above
   already prevents auto-dark from applying when the user picks light, so the
   :root defaults + the active [data-theme] variant supply the light palette.
   This keeps per-theme hues intact in explicit light mode. */

/* 琥珀暗色 — 放在全局暗色之后，同等或更高优先级以覆盖蓝色暗色 */
[data-theme="hupo"][data-color-scheme="dark"] {
  --sg-background: #1F1410;
  --sg-foreground: #F5EFE6;
  --sg-card: #2E1F16;
  --sg-card-foreground: #F5EFE6;
  --sg-popover: #2E1F16;
  --sg-popover-foreground: #F5EFE6;
  --sg-primary: #D49570;
  --sg-primary-light: #E8B488;
  --sg-primary-foreground: #1F1410;
  --sg-muted: #2A1B14;
  --sg-muted-foreground: #C8A98A;
  --sg-border: #4A3826;
  --sg-input: #2E1F16;
  --sg-ring: #D49570;
  --sg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --sg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --sg-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  [data-theme="hupo"]:not([data-color-scheme="light"]) {
    --sg-background: #1F1410;
    --sg-foreground: #F5EFE6;
    --sg-card: #2E1F16;
    --sg-card-foreground: #F5EFE6;
    --sg-popover: #2E1F16;
    --sg-popover-foreground: #F5EFE6;
    --sg-primary: #D49570;
    --sg-primary-light: #E8B488;
    --sg-primary-foreground: #1F1410;
    --sg-muted: #2A1B14;
    --sg-muted-foreground: #C8A98A;
    --sg-border: #4A3826;
    --sg-input: #2E1F16;
    --sg-ring: #D49570;
    --sg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --sg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --sg-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.3);
  }
}

/* Base typography */
html {
  font-family: var(--sg-font-sans);
  color: var(--sg-foreground);
  background-color: var(--sg-background);
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--sg-background);
  color: var(--sg-foreground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Type scale */
.sg-display {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.sg-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.sg-headline {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

.sg-body {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
}

.sg-caption {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--sg-muted-foreground);
}

.sg-small {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

/* Buttons */
.sg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--sg-radius-large);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  background-color: var(--sg-primary);
  color: var(--sg-primary-foreground);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}

.sg-btn:active {
  transform: scale(0.97);
}

.sg-btn-secondary {
  background-color: var(--sg-card);
  color: var(--sg-primary);
  border-color: var(--sg-border);
}

.sg-btn-ghost {
  background-color: transparent;
  color: var(--sg-primary);
}

.sg-btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: var(--sg-radius-medium);
}

.sg-btn-lg {
  height: 52px;
  padding: 0 28px;
  font-size: 16px;
  border-radius: var(--sg-radius-large);
}

/* Cards */
.sg-card {
  background-color: var(--sg-card);
  color: var(--sg-card-foreground);
  border-radius: var(--sg-radius-large);
  border: 1px solid var(--sg-border);
  box-shadow: var(--sg-shadow-sm);
  overflow: hidden;
}

.sg-card-flat {
  box-shadow: none;
}

/* Inputs */
.sg-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--sg-radius-medium);
  border: 1px solid var(--sg-border);
  background-color: var(--sg-input);
  color: var(--sg-foreground);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.sg-input::placeholder {
  color: var(--sg-muted-foreground);
}

.sg-input:focus {
  border-color: var(--sg-ring);
  box-shadow: 0 0 0 3px rgba(35, 87, 150, 0.08);
}

.sg-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--sg-foreground);
}

/* Ticket stub visual */
.sg-ticket {
  position: relative;
  background: var(--sg-card);
  border-radius: var(--sg-radius-large);
  border: 1px solid var(--sg-border);
  overflow: hidden;
}

.sg-ticket::before,
.sg-ticket::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  background-color: var(--sg-background);
  border-radius: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.sg-ticket::before { left: -8px; }
.sg-ticket::after { right: -8px; }

/* Theme swatches */
.sg-swatch-qingkong { background-color: #E6F2FF; }
.sg-swatch-wuyu { background-color: #EEF5FB; }
.sg-swatch-shenhai { background-color: #D6E4F0; }
.sg-swatch-qingyang { background-color: #F0F8FF; }
.sg-swatch-xingye { background-color: #E8F4FF; }

/* Helpers */
.sg-safe-top { padding-top: var(--sg-safe-top); }
.sg-safe-bottom { padding-bottom: var(--sg-safe-bottom); }

/* Animations */
@keyframes sg-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sg-spin {
  to { transform: rotate(360deg); }
}

.sg-animate-fade {
  animation: sg-fade-in 0.35s ease forwards;
}

.sg-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--sg-border);
  border-top-color: var(--sg-primary);
  border-radius: 50%;
  animation: sg-spin 0.8s linear infinite;
}
