/* ==========================================================================
   DailyBook Design System & Global Styles
   "Write. Reflect. Connect."
   ========================================================================== */

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

:root {
  /* Color Palette - Sophisticated Editorial Light */
  --bg-primary: #FAFAF8;
  --bg-surface: #FFFFFF;
  --bg-secondary: #F3F4F1;
  --bg-tertiary: #E8EAE6;
  --text-primary: #171717;
  --text-secondary: #525252;
  --text-muted: #737373;
  --text-inverse: #FFFFFF;

  /* Brand Accents */
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-subtle: #EFF6FF;
  --accent-border: #BFDBFE;

  /* Semantic Feedback */
  --border-color: #E5E7EB;
  --border-light: #F3F4F6;
  --border-dark: #D1D5DB;

  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --danger-light: #FEF2F2;
  --danger-border: #FECACA;

  --success: #16A34A;
  --success-light: #F0FDF4;
  --success-border: #BBF7D0;

  --warning: #D97706;
  --warning-light: #FFFBEB;
  --warning-border: #FDE68A;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Newsreader', 'Merriweather', Georgia, serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Elevations */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.09), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

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

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

  /* Layout dimensions */
  --nav-height: 68px;
  --container-max: 1200px;
  --reading-max: 740px;
}

/* ==========================================================================
   Dark Mode Palette (Intentional Slate/Charcoal)
   ========================================================================== */
[data-theme="dark"] {
  --bg-primary: #0F1115;
  --bg-surface: #171A21;
  --bg-secondary: #1F232B;
  --bg-tertiary: #272C36;
  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --text-inverse: #111827;

  --accent: #3B82F6;
  --accent-hover: #60A5FA;
  --accent-subtle: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(59, 130, 246, 0.28);

  --border-color: #272B35;
  --border-light: #1F232B;
  --border-dark: #373E4D;

  --danger: #EF4444;
  --danger-hover: #F87171;
  --danger-light: rgba(239, 68, 68, 0.14);
  --danger-border: rgba(239, 68, 68, 0.3);

  --success: #22C55E;
  --success-light: rgba(34, 197, 94, 0.14);
  --success-border: rgba(34, 197, 94, 0.3);

  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.14);
  --warning-border: rgba(245, 158, 11, 0.3);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 12px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 20px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 24px 32px -4px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

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

/* ==========================================================================
   Global Layout Structure
   ========================================================================== */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1 0 auto;
  padding-top: calc(var(--nav-height) + 24px);
  padding-bottom: 64px;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}

.reading-container {
  width: 100%;
  max-width: var(--reading-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* ==========================================================================
   Navigation Bar
   ========================================================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

[data-theme="dark"] .site-header {
  background: rgba(15, 17, 21, 0.85);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 20px;
}

/* Brand */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--text-primary);
  color: var(--bg-surface);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}

.nav-brand:hover .brand-icon {
  transform: translateY(-1px);
}

/* Nav Center - Quick Search */
.nav-search {
  flex: 1;
  max-width: 380px;
  position: relative;
}

.nav-search-input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 38px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.nav-search-input:focus {
  background: var(--bg-surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.nav-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.nav-search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  pointer-events: none;
}

/* Nav Right Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

/* User Profile Dropdown in Nav */
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-menu-trigger:hover {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

/* Mobile Nav Toggle */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}

/* Mobile Drawer */
.mobile-drawer {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 99;
  padding: 24px;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--border-color);
  overflow-y: auto;
}

.mobile-drawer.open {
  display: flex;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 48px 0 32px;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand-tagline {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-top: 10px;
  max-width: 280px;
}

.footer-heading {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-link {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--text-primary);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-muted);
}
