/* ==========================================================================
   PLATO - THE REPUBLIC
   Athenian Classical Design System & Study Aid Architecture
   ========================================================================== */

:root {
  /* Athenian Palette */
  --primary: #D4AF37;            /* Athenian Bronze Gold */
  --primary-light: #E5C358;      /* Luminous Amber Gold */
  --primary-dark: #A3841D;       /* Antique Bronze */
  
  --gold: #D4AF37;
  --gold-glow: #F3CA65;
  --gold-muted: #9E7D2B;
  
  --bg-dark: #101014;            /* Obsidian Slate Shadow */
  --surface-dark: #19181F;       /* Athenian Academy Dark Stone */
  --surface-elevated: #24222C;   /* Elevated Card Surface */
  --border-dark: #353240;        /* Subtle Bronze-tinged Border */
  
  --text-primary: #F7F5EE;       /* Warm Attic Marble */
  --text-secondary: #BDB7AB;     /* Athenian Sand */
  --text-muted: #857E74;         /* Soft Aged Papyrus */
  
  --highlight-direct: #D4AF37;   /* Gold query match */
  --highlight-related: #4A90E2;  /* Aegean Blue concept match */
  
  --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;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-gold: 0 4px 20px rgba(212, 175, 55, 0.25);
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Utilities */
.hidden {
  display: none !important;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: #0A090C;
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Simulated Phone Wrapper for Desktop Presentation */
/* Simulated Phone Wrapper (Optimized for Mobile, Centered Aspect-Ratio on Laptop/Tablet) */
.phone-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(circle at 50% 30%, #1c1822 0%, #08070a 100%);
  padding: 20px;
  box-sizing: border-box;
  overflow: hidden;
}

.phone-bezel {
  position: relative;
  /* Lock to phone aspect ratio 9 : 19.5 on desktop, laptops, and tablets */
  height: min(calc(100dvh - 32px), 880px);
  width: calc(min(calc(100dvh - 32px), 880px) * (9 / 19.5));
  max-width: min(430px, calc(100dvw - 32px));
  background-color: #000000;
  border-radius: 48px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(212, 175, 55, 0.2), inset 0 0 0 3px #262428;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

/* True Mobile Phone Screen - edge to edge */
@media (max-width: 480px) {
  .phone-wrapper {
    padding: 0;
  }
  .phone-bezel {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background-color: var(--bg-dark);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  transition: opacity 0.4s ease;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(212, 175, 55, 0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay p {
  font-family: var(--font-serif);
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* Top App Header (Book Detail View) */
.app-header {
  height: 56px;
  background-color: rgba(25, 24, 31, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  flex-shrink: 0;
}

.header-action-btn {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.header-action-btn:hover {
  background-color: rgba(212, 175, 55, 0.1);
}

.book-header-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-primary);
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.header-spacer {
  width: 40px;
}

/* Views & Main Content */
.app-main-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.app-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background-color: var(--bg-dark);
  overflow: hidden;
}

.app-view.active {
  display: flex;
}

.view-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 84px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Top View Heading */
.view-heading {
  margin-bottom: 18px;
}

.view-heading h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.view-heading p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* -------------------------------------------------------------
   1. DASHBOARD / HERO / DAILY WISDOM
   ------------------------------------------------------------- */
.hero-card {
  position: relative;
  width: 100%;
  height: 240px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-dark);
  margin-bottom: 18px;
  box-shadow: var(--shadow-md);
}

.hero-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
}

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

.hero-badge-container {
  position: absolute;
  bottom: 16px;
  left: 18px;
  right: 18px;
}

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

.hero-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: 2px;
  line-height: 1.1;
  margin-bottom: 6px;
}

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

.renaissance-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0 20px;
  color: var(--gold);
  opacity: 0.6;
}

.renaissance-divider::before,
.renaissance-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-dark), transparent);
}

.renaissance-divider svg {
  margin: 0 12px;
}

/* Daily Maxim Card */
.maxim-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--gold);
  text-transform: uppercase;
}

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

.card-media {
  width: 100%;
  height: 180px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border-dark);
}

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

.card-body {
  margin-bottom: 16px;
}

.passage-quote {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  font-style: italic;
  position: relative;
  padding-left: 14px;
  border-left: 2px solid var(--gold);
}

.card-actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: var(--font-sans);
}

.btn-primary {
  background: var(--gold);
  color: #111;
  flex: 1;
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-dark);
  flex: 1;
}

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

/* -------------------------------------------------------------
   2. BROWSE / CHAPTERS GRID & READING
   ------------------------------------------------------------- */
.books-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card-item {
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.book-card-item:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  background: var(--surface-elevated);
}

.book-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.book-card-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 1px;
}

.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
}

.book-card-subtitle {
  font-size: 13px;
  color: var(--gold);
  line-height: 1.4;
  margin-bottom: 10px;
}

.book-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Chapter Detail Toolbar */
.chapter-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0 16px;
  padding: 8px 12px;
  background: var(--surface-dark);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
}

.chapter-quick-actions {
  display: flex;
  gap: 8px;
}

.btn-pill-small {
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-pill-small:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* Section Jump Bar */
.section-jump-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.section-jump-bar::-webkit-scrollbar {
  display: none;
}

.jump-pill {
  flex-shrink: 0;
  background: var(--surface-elevated);
  border: 1px solid var(--border-dark);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition);
}

.jump-pill:hover, .jump-pill.active {
  border-color: var(--gold);
  color: var(--gold);
}

/* Passages Stream */
.passages-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.passage-item-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: var(--transition);
  position: relative;
}

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

.passage-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
}

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

.passage-item-actions {
  display: flex;
  gap: 8px;
}

.action-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}

.action-icon-btn:hover {
  color: var(--gold);
}

.passage-item-text {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-primary);
  user-select: text;
  -webkit-user-select: text;
}

.passage-item-card.collapsed .passage-item-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.7;
}

/* -------------------------------------------------------------
   3. SEARCH & CONCEPT CHIPS
   ------------------------------------------------------------- */
.search-bar-wrap {
  position: relative;
  margin-bottom: 14px;
}

.search-icon-left {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-box {
  width: 100%;
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-pill);
  padding: 12px 40px 12px 42px;
  font-size: 14px;
  color: #FFFFFF;
  outline: none;
  font-family: var(--font-sans);
  transition: var(--transition);
}

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

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

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.concept-chip {
  background: var(--surface-elevated);
  border: 1px solid var(--border-dark);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition);
}

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

.query-highlight {
  background-color: rgba(212, 175, 55, 0.35);
  color: #FFFFFF;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 600;
}

/* -------------------------------------------------------------
   4. SETTINGS & EDITION INFO
   ------------------------------------------------------------- */
.settings-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 14px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-text h3 {
  font-size: 15px;
  font-weight: 600;
  color: #FFFFFF;
  margin-bottom: 4px;
}

.settings-text p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------
   BOTTOM NAVIGATION BAR (4 PILLARS)
   ------------------------------------------------------------- */
.app-bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 68px;
  background-color: rgba(25, 24, 31, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-dark);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

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

.nav-tab svg {
  transition: transform 0.2s ease;
}

.nav-tab span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

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

.nav-tab.active svg {
  transform: scale(1.1);
}

/* -------------------------------------------------------------
   FOCUS READER MODAL
   ------------------------------------------------------------- */
.reader-modal {
  position: absolute;
  inset: 0;
  background-color: var(--bg-dark);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

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

.reader-title-info {
  display: flex;
  flex-direction: column;
}

.reader-chapter-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
}

.reader-sec-count {
  font-size: 11px;
  color: var(--gold);
}

.reader-font-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reader-font-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--border-dark);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.reader-body-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-quote-container {
  max-width: 580px;
  width: 100%;
}

.reader-text {
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.85;
  color: #FFFFFF;
  user-select: text;
  -webkit-user-select: text;
}

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

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

.btn-reader-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Toast */
.toast-notice {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: rgba(25, 24, 31, 0.95);
  border: 1px solid var(--gold);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-gold);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
}

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

/* Media Queries for True Mobile Full Screen */
/* Classical Scroll Ecosystem Return Ribbon */
.cs-hub-header-bar {
  background: rgba(10, 10, 14, 0.95);
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.cs-hub-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #D4AF37;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: opacity 0.2s;
}
.cs-hub-back-link:hover {
  opacity: 0.8;
}


.cs-hub-motto {
  font-size: 10px;
  font-style: italic;
  color: rgba(212, 175, 55, 0.7);
  letter-spacing: 0.3px;
  display: none;
}
@media (min-width: 380px) {
  .cs-hub-motto {
    display: inline-block;
  }
}

.cs-manifesto-card {
  background: var(--surface-dark, #18171e) !important;
  border-left: 3px solid var(--gold, #d4af37) !important;
}
.manifesto-tag {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--gold, #d4af37);
  margin-bottom: 4px;
  text-transform: uppercase;
}
.cs-manifesto-card h3 {
  font-style: italic;
  font-size: 13px;
  color: #ffffff;
  margin-bottom: 6px;
  line-height: 1.4;
}
.cs-manifesto-card p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary, #b0aab9);
}
