/* ==========================================================================
   CLASSICAL SCROLL — UNIVERSAL STUDY ENGINE STYLES
   Canonic Theming, Responsive Mobile-Bezel, 4-Pillar Layout & Focus Reader
   ========================================================================== */

/* Canonic Themes applied to #study-engine-container */
#study-engine-container[data-canon="athenian"] {
  --primary: #D4AF37;
  --primary-light: #E5C358;
  --primary-dark: #8F7218;
  --gold: #D4AF37;
  --gold-glow: #F3CA65;
  --gold-muted: #9E7D2B;
  --bg-dark: #101014;
  --surface-dark: #19181F;
  --surface-elevated: #24222C;
  --border-dark: #353240;
}

#study-engine-container[data-canon="stoic"] {
  --primary: #C5A059;
  --primary-light: #D8B775;
  --primary-dark: #7A5F26;
  --gold: #C5A059;
  --gold-glow: #E2C78E;
  --gold-muted: #8E733B;
  --bg-dark: #141416;
  --surface-dark: #1E1E22;
  --surface-elevated: #28282E;
  --border-dark: #3A3A42;
}

#study-engine-container[data-canon="victorian"] {
  --primary: #2E6F56;
  --primary-light: #3D8C6E;
  --primary-dark: #1B4535;
  --gold: #D4AF37;
  --gold-glow: #F3CA65;
  --gold-muted: #9E7D2B;
  --bg-dark: #101312;
  --surface-dark: #181C1B;
  --surface-elevated: #232927;
  --border-dark: #2F3734;
}

#study-engine-container[data-canon="baroque"] {
  --primary: #9E1B1B;
  --primary-light: #C0392B;
  --primary-dark: #660B0B;
  --gold: #D4AF37;
  --gold-glow: #F3CA65;
  --gold-muted: #9E7D2B;
  --bg-dark: #121013;
  --surface-dark: #1C181E;
  --surface-elevated: #28222C;
  --border-dark: #38303E;
}

/* Master Overlay */
#study-engine-container {
  --text-primary: #F7F4EB;
  --text-secondary: #B8B2A6;
  --text-muted: #857E74;
  --font-serif: 'Cinzel', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  position: fixed;
  inset: 0;
  z-index: 5000;
  background: radial-gradient(circle at 50% 25%, #1c1822 0%, #070608 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.25s ease;
  user-select: none;
}

#study-engine-container.hidden {
  display: none !important;
}

/* Phone Bezel and Screen */
.reader-phone-bezel {
  width: 100%;
  max-width: 440px;
  height: 100%;
  max-height: 920px;
  background-color: var(--bg-dark);
  border-radius: 40px;
  border: 8px solid #25222b;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(212, 175, 55, 0.25);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (max-width: 600px) {
  .reader-phone-bezel {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
}

.reader-phone-screen {
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

/* Top App Header */
.reader-top-header {
  height: 56px;
  background-color: rgba(26, 23, 30, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 40;
  flex-shrink: 0;
}

.reader-exit-btn {
  background: transparent;
  border: none;
  color: var(--gold);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  transition: var(--transition);
}

.reader-exit-btn:hover {
  background-color: rgba(212, 175, 55, 0.15);
}

.reader-header-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #FFFFFF;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  text-align: center;
}

.reader-header-share-btn {
  background: transparent;
  border: none;
  color: var(--gold);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.reader-header-share-btn:hover {
  background-color: rgba(212, 175, 55, 0.15);
}

/* Main Content Switcher */
.reader-main-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.reader-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow: hidden;
}

.reader-view.active {
  display: flex;
  opacity: 1;
}

.reader-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 84px;
  -webkit-overflow-scrolling: touch;
}

/* Paywall / Preview Banner */
.reader-access-banner {
  background: linear-gradient(135deg, var(--surface-dark) 0%, var(--surface-elevated) 100%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reader-access-info h4 {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reader-access-info p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-unlock-single {
  background: var(--gold);
  color: #121013;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.btn-unlock-single:hover {
  background: var(--gold-glow);
  transform: translateY(-1px);
}

/* Hero Author Card */
.reader-hero-card {
  position: relative;
  width: 100%;
  height: 210px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.reader-hero-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: transform 0.5s ease;
}

.reader-hero-card:hover img {
  transform: scale(1.04);
}

.reader-hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 16, 20, 0) 0%, rgba(16, 16, 20, 0.4) 40%, rgba(16, 16, 20, 0.95) 100%);
}

.reader-hero-info {
  position: absolute;
  bottom: 16px;
  left: 18px;
  right: 18px;
}

.reader-hero-tag {
  font-family: var(--font-serif);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 4px;
}

.reader-hero-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 800;
  color: #FFF;
  letter-spacing: 1px;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.reader-hero-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Ornament Divider */
.reader-ornament-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 18px 0;
}

.reader-ornament-divider::before,
.reader-ornament-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-muted), transparent);
}

.reader-ornament-divider svg {
  color: var(--gold);
  opacity: 0.85;
}

/* Daily Maxim Card */
.reader-maxim-card {
  background-color: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.reader-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.reader-card-tag {
  font-family: var(--font-serif);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--gold);
  font-weight: 700;
}

.reader-card-ref {
  font-size: 11px;
  color: var(--text-muted);
}

.reader-card-media {
  width: 100%;
  height: 170px;
  overflow: hidden;
}

.reader-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reader-card-body {
  padding: 16px 18px;
}

.reader-card-body blockquote {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
  font-style: italic;
}

.reader-card-actions {
  display: flex;
  gap: 10px;
  padding: 0 18px 16px 18px;
}

.reader-card-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.reader-card-btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #FFF;
}

.reader-card-btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.4);
}

/* Chapters Pillar */
.reader-heading {
  margin-bottom: 16px;
}

.reader-heading h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 1px;
}

.reader-heading p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.reader-chapters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.reader-chapter-item {
  background-color: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.reader-chapter-item:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.reader-chapter-thumb {
  width: 100%;
  height: 100px;
  overflow: hidden;
  position: relative;
  background-color: #0b0a0d;
}

.reader-chapter-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reader-chapter-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background-color: rgba(18, 16, 20, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: var(--gold);
  font-family: var(--font-serif);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.reader-chapter-locked {
  position: absolute;
  top: 6px;
  right: 6px;
  background-color: rgba(18, 16, 20, 0.85);
  color: #E74C3C;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
}

.reader-chapter-meta {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.reader-ch-title {
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.reader-ch-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

/* Chapter Detail View Inside Reader */
.reader-detail-banner {
  width: 100%;
  height: 160px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
  position: relative;
  border: 1px solid rgba(212, 175, 55, 0.25);
}

.reader-detail-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reader-detail-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(18, 16, 20, 0.95) 100%);
  display: flex;
  align-items: flex-end;
  padding: 14px;
}

.reader-detail-banner-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: #FFF;
}

.reader-chapter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.reader-quick-btn {
  background-color: var(--surface-dark);
  border: 1px solid var(--border-dark);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.reader-quick-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* Passage Card */
.reader-passage-card {
  background-color: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.reader-passage-card:hover {
  border-color: rgba(212, 175, 55, 0.4);
}

.reader-passage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.reader-sec-tag {
  font-family: var(--font-serif);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 1px;
  font-weight: 700;
}

.reader-passage-text {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}

.reader-passage-card.collapsed .reader-passage-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-secondary);
}

.reader-passage-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.reader-btn-read-focus {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Search Pillar */
.reader-search-wrap {
  position: relative;
  margin-bottom: 14px;
}

.reader-search-input {
  width: 100%;
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-pill);
  padding: 10px 38px 10px 38px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.reader-search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.reader-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  pointer-events: none;
}

.reader-search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.reader-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.reader-chip {
  background-color: var(--surface-dark);
  border: 1px solid var(--border-dark);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition);
}

.reader-chip:hover,
.reader-chip.active {
  border-color: var(--gold);
  color: var(--gold);
  background-color: rgba(212, 175, 55, 0.12);
}

/* Tools / Settings Pillar */
.reader-settings-card {
  background-color: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.reader-settings-card h3 {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 6px;
}

.reader-settings-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.reader-license-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-dark);
  color: var(--gold);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Dedicated Focus Modal */
.reader-focus-modal {
  position: absolute;
  inset: 0;
  background-color: var(--bg-dark);
  z-index: 120;
  display: flex;
  flex-direction: column;
}

.reader-focus-header {
  height: 52px;
  background-color: var(--surface-dark);
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.reader-focus-titles {
  display: flex;
  flex-direction: column;
}

.reader-focus-ch-title {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

.reader-focus-sec-title {
  font-size: 10px;
  color: var(--text-muted);
}

.reader-focus-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reader-font-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--border-dark);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.reader-font-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.reader-focus-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  -webkit-overflow-scrolling: touch;
}

.reader-focus-quote-box {
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.reader-focus-quote-box::before {
  content: '“';
  position: absolute;
  top: 4px;
  left: 14px;
  font-family: var(--font-serif);
  font-size: 48px;
  color: rgba(212, 175, 55, 0.15);
  line-height: 1;
  pointer-events: none;
}

.reader-focus-text {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-primary);
  position: relative;
  z-index: 2;
}

.reader-focus-bottom {
  background-color: var(--surface-dark);
  border-top: 1px solid var(--border-dark);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.btn-focus-step {
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-dark);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-focus-step:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-focus-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 4-Pillar Bottom Nav */
.reader-bottom-nav {
  height: 64px;
  background-color: rgba(24, 21, 28, 0.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-dark);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  flex-shrink: 0;
}

.reader-nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  cursor: pointer;
  gap: 3px;
  transition: var(--transition);
}

.reader-nav-tab.active {
  color: var(--gold);
}

.reader-nav-tab span {
  font-size: 10px;
  font-weight: 600;
}

/* Toast */
.reader-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: rgba(26, 23, 30, 0.95);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 200;
  white-space: nowrap;
}

.reader-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
