/* ==========================================================================
   Modern Kırmızı Tema (KırmızıTheme) — HITLAB-Inspired Design System
   ========================================================================== */

:root {
  /* Color Palette (kirmizitheme.md) */
  --bg: #ffffff;
  --bg-subtle: #f5f5f5;
  --bg-muted: #eeeeee;

  --text: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #999999;

  --accent: #e53935;
  --accent-hover: #c62828;
  --accent-light: rgba(229, 57, 53, 0.08);

  --blue: #2563eb;
  --blue-light: rgba(37, 99, 235, 0.08);
  --success: #16a34a;
  --border: #e0e0e0;
  --border-hover: #bdbdbd;

  /* Shadows & Radius */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --radius-lg: 12px;

  /* Typography */
  --font-sans: 'Google Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Playfair Display', Lora, Georgia, serif;
  --fs-base: 16px;
  --lh-reader: 1.6;
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 16px 32px 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

/* Views Management */
.view {
  display: none;
}
.view.active {
  display: block;
}

/* ==========================================================================
   1. LIBRARY VIEW — KırmızıTheme Card Grid
   ========================================================================== */

.library-header {
  margin-bottom: 24px;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background-color: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(229, 57, 53, 0.15);
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.brand .subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 1px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.book-card {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.book-card:active, .book-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.book-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}

.book-card-author {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.book-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 12px 0 20px 0;
}

.book-card-action {
  display: flex;
  justify-content: flex-end;
}

.btn-read {
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.btn-read:hover {
  background-color: var(--accent-hover);
}

.btn-read:active {
  transform: scale(0.98);
}

/* ==========================================================================
   2. READER VIEW — KırmızıTheme Layout & Components
   ========================================================================== */

.reader-card {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

/* Topbar */
.reader-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon-custom {
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-icon-custom:hover {
  background: var(--bg-subtle);
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-icon-custom:active {
  transform: scale(0.98);
}

.font-btn {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  padding: 0 8px;
  width: auto;
  min-width: 38px;
}

.title-meta .book-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.title-meta .book-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 3px;
  background-color: var(--bg-muted);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--accent);
  transition: width 0.35s ease;
}

/* Columns Header */
.columns-header {
  display: grid;
  grid-template-columns: 60% 40%;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-subtle);
}

.col-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
}

.col-tr-label {
  padding-left: 18px;
}

/* Reader Content */
.reader-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 320px;
}

/* Animation Keyframes */
@keyframes slideNextIn {
  0% {
    opacity: 0;
    transform: translateX(18px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slidePrevIn {
  0% {
    opacity: 0;
    transform: translateX(-18px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.reader-content.slide-next {
  animation: slideNextIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.reader-content.slide-prev {
  animation: slidePrevIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Sentence Row Item (Desktop: 60% / 40%) */
.sentence-row {
  display: grid;
  grid-template-columns: 60% 40%;
  border-radius: var(--radius);
  background-color: var(--bg);
  border: 1px solid var(--border);
  padding: 16px 18px;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.sentence-row:hover {
  background-color: var(--accent-light);
  border-color: rgba(229, 57, 53, 0.3);
}

/* English Text Column (60%) */
.en-col {
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  line-height: var(--lh-reader);
  color: var(--text);
  padding-right: 18px;
  position: relative;
}

/* Turkish Text Column (40%) */
.tr-col {
  font-family: var(--font-sans);
  font-size: calc(var(--fs-base) - 1px);
  line-height: var(--lh-reader);
  color: var(--text-secondary);
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

/* Inline TTS Speaker Button (Red Accent Tint) */
.tts-inline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border: 1px solid rgba(229, 57, 53, 0.2);
  color: var(--accent);
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.tts-inline-btn:active, .tts-inline-btn:hover {
  transform: scale(1.1);
  background: var(--accent);
  color: #ffffff;
}

/* Bottom Navigation Bar */
.reader-bottombar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background-color: var(--bg-subtle);
  gap: 12px;
}

.counter-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.nav-btn-custom {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.nav-btn-custom:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--border-hover);
  color: var(--text);
}

.nav-btn-custom:active:not(:disabled) {
  transform: scale(0.98);
}

.nav-btn-primary {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.nav-btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.nav-btn-custom:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Skeleton Loading Animation */
.skeleton {
  background: linear-gradient(90deg, #eeeeee 25%, #f5f5f5 50%, #eeeeee 75%);
  background-size: 200% 100%;
  animation: loadingSkeleton 1.5s infinite;
  border-radius: 4px;
  display: inline-block;
  height: 1.2em;
  width: 85%;
}

@keyframes loadingSkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   MOBILE OPTIMIZATION (iPhone & Android Phones <= 680px)
   ========================================================================== */

@media (max-width: 680px) {
  body {
    padding: 10px 10px 24px 10px;
  }

  .library-header {
    margin-bottom: 16px;
  }

  .brand h1 {
    font-size: 20px;
  }

  .columns-header {
    display: none;
  }

  .reader-topbar {
    padding: 12px 16px;
  }

  .reader-content {
    padding: 12px 14px;
    gap: 10px;
    min-height: 280px;
  }

  /* Stacked Sentence Cards on Mobile — Uses dynamic --fs-base variable! */
  .sentence-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 16px;
    border-radius: var(--radius-lg);
  }

  .en-col {
    padding-right: 0;
    font-size: var(--fs-base);
    line-height: 1.6;
  }

  .tr-col {
    padding-left: 0;
    border-left: none;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    font-size: calc(var(--fs-base) - 1px);
    line-height: 1.55;
    color: var(--text-secondary);
  }

  .reader-bottombar {
    padding: 12px 14px;
  }

  .nav-btn-custom {
    padding: 0 12px;
    height: 40px;
    font-size: 13px;
  }

  .counter-badge {
    padding: 4px 10px;
    font-size: 12px;
  }
}
