/* ==========================================================================
   KINDLE E-INK EDITORIAL DESIGN SYSTEM
   Tối Giản - Tinh Tế - Sang Trọng - Dịu Mắt (Anti-Eye-Fatigue)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Literata:ital,opsz,wght@0,7..72,300..700;1,7..72,300..700&family=Merriweather:ital,wght@0,300;0,400;0,700;1,300&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Font Stacks */
  --font-serif: 'Literata', 'Merriweather', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  /* Typography Scale */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */

  /* Spacing */
  --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;

  /* Reader View Variables (Tùy biến động bằng JS) */
  --reader-font-size: 18px;
  --reader-line-height: 1.8;
  --reader-font-family: var(--font-serif);
  --reader-max-width: 780px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Elevation */
  --shadow-paper: 0 1px 3px rgba(35, 30, 20, 0.05), 0 4px 12px rgba(35, 30, 20, 0.03);
  --shadow-float: 0 8px 30px rgba(35, 30, 20, 0.08), 0 2px 6px rgba(35, 30, 20, 0.04);
  --shadow-modal: 0 20px 45px rgba(25, 20, 10, 0.16);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

/* ==========================================================================
   THEMES: 4 CHẾ ĐỘ MÀU DỊU MẮT
   ========================================================================== */

/* 1. Warm Paper (Mặc Định - Chuẩn Kindle Oasis) */
:root,
[data-theme="warm"] {
  --bg-primary: #FAF6ED;
  --bg-surface: #F2ECE0;
  --bg-card: #FDFCFA;
  --bg-input: #FFFFFF;
  --border-subtle: rgba(45, 38, 25, 0.10);
  --border-strong: rgba(45, 38, 25, 0.22);
  --text-ink: #242628;
  --text-secondary: #5E636A;
  --text-muted: #848A93;
  --accent: #8C5E35;
  --accent-soft: #F0E5D7;
  --accent-contrast: #FFFFFF;
  --progress-track: rgba(45, 38, 25, 0.08);
  --progress-fill: #8C5E35;
  --badge-bg: #EAE1D0;
  --badge-text: #5A3E24;
}

/* 2. Sepia Vintage (Hoài Cổ Hổ Phách) */
[data-theme="sepia"] {
  --bg-primary: #F5EBD4;
  --bg-surface: #EADDBF;
  --bg-card: #FCF6E8;
  --bg-input: #FAF3E3;
  --border-subtle: rgba(70, 48, 20, 0.12);
  --border-strong: rgba(70, 48, 20, 0.26);
  --text-ink: #382A1B;
  --text-secondary: #6B5742;
  --text-muted: #8E7C67;
  --accent: #9A622A;
  --accent-soft: #ECD8B8;
  --accent-contrast: #FFFFFF;
  --progress-track: rgba(70, 48, 20, 0.10);
  --progress-fill: #9A622A;
  --badge-bg: #E2CFAB;
  --badge-text: #4E3214;
}

/* 3. Chalk Gray (Trắng Giấy Sạch Sẽ) */
[data-theme="chalk"] {
  --bg-primary: #F7F7F8;
  --bg-surface: #ECECEE;
  --bg-card: #FFFFFF;
  --bg-input: #FFFFFF;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.20);
  --text-ink: #1C1E21;
  --text-secondary: #585E65;
  --text-muted: #7E868F;
  --accent: #3A4B5C;
  --accent-soft: #E3E8ED;
  --accent-contrast: #FFFFFF;
  --progress-track: rgba(0, 0, 0, 0.06);
  --progress-fill: #3A4B5C;
  --badge-bg: #E1E5EA;
  --badge-text: #2A3642;
}

/* 4. Onyx E-Ink Night (Chế Độ Đêm Dịu Nhẹ) */
[data-theme="night"] {
  --bg-primary: #151618;
  --bg-surface: #1E2023;
  --bg-card: #25282D;
  --bg-input: #1B1D20;
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.20);
  --text-ink: #E4E1D8;
  --text-secondary: #9C9FA6;
  --text-muted: #70747C;
  --accent: #D7AA77;
  --accent-soft: #30281F;
  --accent-contrast: #161719;
  --progress-track: rgba(255, 255, 255, 0.08);
  --progress-fill: #D7AA77;
  --badge-bg: #2C2822;
  --badge-text: #D7AA77;
}

/* ==========================================================================
   RESET & GLOBAL STYLES
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

/* Paper grain micro-texture overlay (subtle e-ink tactile feel) */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.022;
  background-image: radial-gradient(#000 0.75px, transparent 0.75px);
  background-size: 6px 6px;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  transition: all var(--transition-fast);
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* Custom Eye-Friendly Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Selection highlight soft warm ink */
::selection {
  background-color: var(--accent-soft);
  color: var(--text-ink);
}
