/* ==========================================================================
   MOE Tamil Interactive eBook - Main Styles
   ========================================================================== */

/* CSS Variables / Design Tokens */
:root {
  /* Colors - Rich, Premium Palette */
  --primary-color: #8b4513;
  --primary-light: #a0522d;
  --primary-dark: #6b3410;
  --secondary-color: #daa520;
  --secondary-light: #ffd700;
  --accent-color: #2e8b57;
  --accent-light: #3cb371;

  /* Background Colors */
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-overlay: rgba(0, 0, 0, 0.7);

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #b8b8b8;
  --text-muted: #6c757d;
  --text-dark: #1a1a2e;

  /* Book Colors */
  --book-cover: linear-gradient(145deg, #8b4513 0%, #5d3a1a 50%, #3e2712 100%);
  --book-page: #fdf5e6;
  --book-page-alt: #faf0e6;
  --book-spine: #3e2712;
  --book-shadow: rgba(0, 0, 0, 0.4);

  /* UI Colors */
  --border-color: rgba(255, 255, 255, 0.1);
  --border-light: rgba(255, 255, 255, 0.2);
  --success-color: #28a745;
  --warning-color: #ffc107;
  --error-color: #dc3545;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.3);
  --glow: 0 0 20px rgba(218, 165, 32, 0.3);

  /* Typography */
  --font-primary: "Segoe UI", "Noto Sans Tamil", system-ui, sans-serif;
  --font-tamil: "Noto Sans Tamil", "Latha", "Vijaya", sans-serif;
  --font-mono: "Consolas", "Monaco", monospace;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 3rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 50%;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Z-index layers */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sidebar: 200;
  --z-toolbar: 300;
  --z-modal: 400;
  --z-loading: 500;

  /* Book dimensions */
  --book-width: 600px;
  --book-height: 800px;
  --toolbar-height: 60px;
  --sidebar-width: 300px;
}

/* Light theme override */
[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9ecef;
  --text-primary: #1a1a2e;
  --text-secondary: #495057;
  --border-color: rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Loading Screen
   ========================================================================== */

.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-loading);
  transition:
    opacity var(--transition-slow),
    visibility var(--transition-slow);
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader {
  text-align: center;
}

.book-loader {
  width: 60px;
  height: 80px;
  position: relative;
  perspective: 1000px;
  margin: 0 auto var(--spacing-lg);
}

.book-loader .page {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--book-page);
  border-radius: var(--radius-sm);
  transform-origin: left center;
  animation: flipPage 1.5s infinite ease-in-out;
  box-shadow: var(--shadow-md);
}

.book-loader .page:nth-child(1) {
  animation-delay: 0s;
}
.book-loader .page:nth-child(2) {
  animation-delay: 0.15s;
}
.book-loader .page:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes flipPage {
  0%,
  100% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(-180deg);
  }
}

.loader p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* ==========================================================================
   App Container
   ========================================================================== */

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(
    135deg,
    var(--bg-primary) 0%,
    var(--bg-secondary) 50%,
    var(--bg-tertiary) 100%
  );
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center {
  text-align: center;
}
.text-left {
  text-align: left;
}
.text-right {
  text-align: right;
}

.flex {
  display: flex;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Button Styles
   ========================================================================== */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--secondary-color);
  transform: scale(1.05);
}

.btn-icon:active {
  transform: scale(0.95);
}

.btn-icon:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-lg);
  background: linear-gradient(
    135deg,
    var(--secondary-color),
    var(--secondary-light)
  );
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-dark);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--glow);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ==========================================================================
   Scrollbar Styles
   ========================================================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-light);
}

/* ==========================================================================
   Selection Styles
   ========================================================================== */

::selection {
  background: var(--secondary-color);
  color: var(--text-dark);
}

::-moz-selection {
  background: var(--secondary-color);
  color: var(--text-dark);
}

/* ==========================================================================
   Tamil Text Styling
   ========================================================================== */

.tamil-text {
  font-family: var(--font-tamil);
  line-height: 1.8;
}

/* ==========================================================================
   Responsive Base
   ========================================================================== */

@media screen and (max-width: 768px) {
  :root {
    --book-width: 100%;
    --book-height: auto;
    --sidebar-width: 280px;
    --toolbar-height: 50px;
  }

  html {
    font-size: 14px;
  }
}

@media screen and (max-width: 480px) {
  :root {
    --sidebar-width: 100%;
  }

  html {
    font-size: 13px;
  }
}
