/* ============================================================
   Warm Paper — Design System
   Design tokens, base reset, layout, animations.
   Reusable components are in examples/tw_source.css (@layer components).
   ============================================================ */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  /* --- Typography --- */
  --font-display: "DM Sans", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Noto Sans SC", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  --leading-tight: 1.25;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  --tracking-tight: -0.02em;
  --tracking-normal: -0.01em;
  --tracking-wide: 0.02em;

  /* --- Spacing scale --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* --- Radii --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* --- Shadows --- */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.07), 0 4px 12px rgba(0, 0, 0, 0.04);

  /* --- Transitions --- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* --- Light theme colors --- */
  --color-bg:             #faf9f6;
  --color-surface:        #ffffff;
  --color-surface-hover:  #f6f5f2;
  --color-surface-raised: #fcfbfa;

  --color-text-primary:   #1c1b1a;
  --color-text-secondary: #6b6965;
  --color-text-tertiary:  #9c9a95;

  --color-border:         #e7e5e0;
  --color-border-light:   #f0eeea;
  --color-border-hover:   #d8d5cf;

  /* Accent — muted slate blue */
  --color-accent:           #5b6e8f;
  --color-accent-hover:     #4a5c7a;
  --color-accent-active:    #3d4e68;
  --color-accent-light:     #eff1f5;
  --color-accent-subtle:    #f5f6f9;
  --color-on-accent:        #ffffff;

  /* Semantic */
  --color-success:          #4d7a5a;
  --color-success-light:    #edf5ef;
  --color-warning:          #b0803a;
  --color-warning-light:    #faf5ed;
  --color-error:            #b8544a;
  --color-error-light:      #faf1ef;

  /* Focus ring */
  --color-focus-ring:       rgba(91, 110, 143, 0.25);
  --focus-ring-width:       3px;
}

/* ============================================================
   DARK THEME
   ============================================================ */

.dark {
  --color-bg:             #131311;
  --color-surface:        #1c1c1a;
  --color-surface-hover:  #242421;
  --color-surface-raised: #21211f;

  --color-text-primary:   #eeedeb;
  --color-text-secondary: #9d9b97;
  --color-text-tertiary:  #6b6965;

  --color-border:         #2e2d2a;
  --color-border-light:   #262522;
  --color-border-hover:   #3d3c38;

  --color-accent:           #8b9ec4;
  --color-accent-hover:     #9badd0;
  --color-accent-active:    #7a8fb8;
  --color-accent-light:     #232830;
  --color-accent-subtle:    #1f2127;
  --color-on-accent:        #131311;

  --color-success:          #6daa76;
  --color-success-light:    #1c2620;
  --color-warning:          #d4a558;
  --color-warning-light:    #28241c;
  --color-error:            #d46e62;
  --color-error-light:      #28201f;

  --color-focus-ring:       rgba(139, 158, 196, 0.3);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.16), 0 1px 2px rgba(0, 0, 0, 0.10);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.10);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ============================================================
   BASE RESET & GLOBALS
   ============================================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  transition: background-color var(--duration-slow) var(--ease-out),
              color var(--duration-slow) var(--ease-out);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Typography --- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  margin: 0;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  margin: 0 0 var(--space-4);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--color-accent-hover);
}

img, svg {
  max-width: 100%;
  display: block;
}

/* --- Focus styles --- */

:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- Selection --- */

::selection {
  background-color: var(--color-accent-light);
  color: var(--color-text-primary);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  border-bottom: 1px solid var(--color-border-light);
  background-color: var(--color-surface);
  transition: background-color var(--duration-slow) var(--ease-out),
              border-color var(--duration-slow) var(--ease-out);
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  width: 100%;
}

/* --- App page layout (shared by account & customer) --- */
.app-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);
}

.account-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
}

/* ============================================================
   RAW INPUT OVERRIDES
   (django-allauth renders bare <input> without class)
   ============================================================ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="tel"] {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover {
  border-color: var(--color-border-hover);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 var(--focus-ring-width) var(--color-focus-ring);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--color-accent);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* ============================================================
   DARK MODE TOGGLE ICON VISIBILITY
   ============================================================ */

.dark .theme-toggle .icon-sun { display: block; }
.dark .theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fade-in-up var(--duration-slow) var(--ease-out) both;
}

.animate-fade-in-up:nth-child(1) { animation-delay: 0ms; }
.animate-fade-in-up:nth-child(2) { animation-delay: 80ms; }
.animate-fade-in-up:nth-child(3) { animation-delay: 160ms; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
  .account-card {
    padding: var(--space-6) var(--space-5);
    border-radius: var(--radius-lg);
  }

  .account-card h1 {
    font-size: var(--text-2xl);
  }

  .site-header-inner {
    padding: 0 var(--space-4);
  }
}
