/*
 * MARCUS TULLIUS CICERO — DE OFFICIIS (ON DUTIES)
 * Classical Scroll App Theme
 */


:root {
  /* Dionysian Palette */
  --primary: #2E7D32;            /* Solar Flame / Dionysian Amber */
  --primary-light: #66BB6A;      /* Luminous Sunrise Gold */
  --primary-dark: #C63F17;       /* Deep Volcanic Ember */
  
  --gold: #D4AF37;               /* Antique Gold */
  --gold-glow: #F3CA65;
  --gold-muted: #9E7D2B;
  
  --bg-dark: #0F0E11;            /* Alpine Obsidian Shadow */
  --surface-dark: #18171E;       /* Sils Maria Granite Slate */
  --surface-elevated: #24222D;   /* Elevated Card Surface */
  --border-dark: #373344;        /* Subtle Bronze Border */
  
  --text-primary: #F9F7F2;       /* Crisp High-Mountain Snow */
  --text-secondary: #C5BFB2;     /* Alpine Granite Sand */
  --text-muted: #8E887E;         /* Weathered Slate */
  
  --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-fire: 0 4px 20px rgba(255, 112, 67, 0.25);
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.hidden { display: none !important; }

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

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

/* Simulated Phone Wrapper */
/* 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%, #1e1b24 0%, #060507 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(255, 112, 67, 0.2), inset 0 0 0 3px #28242a;
  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;
  }
}

/* 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;
}

/* 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(255, 112, 67, 0.2);
  border-top-color: var(--primary);
  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(--primary-light);
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

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

/* App Header (Chapter Detail) */
.app-header {
  height: 56px;
  background: rgba(24, 23, 30, 0.95);
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
}

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

.header-action-btn:hover {
  background: rgba(255, 112, 67, 0.1);
}

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

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

.app-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

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

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

/* 1. Dashboard View */
.hero-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 22px;
  height: 230px;
  border: 1px solid var(--border-dark);
  cursor: pointer;
}

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

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

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 14, 17, 0.1) 0%, rgba(15, 14, 17, 0.85) 70%, rgba(15, 14, 17, 0.98) 100%);
}

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

.hero-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 4px;
}

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

/* Ornamental Divider */
.dionysian-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0 20px;
  color: var(--primary);
  opacity: 0.6;
}

.dionysian-divider::before, .dionysian-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 112, 67, 0.3), transparent);
}

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

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

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

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

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

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

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

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

.passage-quote {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  font-style: italic;
}

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

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

.btn-primary {
  background: var(--primary);
  color: #000000;
  border: none;
}

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

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

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

/* 2. Chapters View */
.view-heading {
  margin-bottom: 18px;
}

.view-heading h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

.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: 14px 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
}

.book-card-item:hover {
  border-color: rgba(255, 112, 67, 0.4);
  transform: translateY(-1px);
}

.book-card-thumb {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-dark);
}

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

.book-card-content {
  flex: 1;
  min-width: 0;
}

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

.book-card-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Chapter Detail Passages */
.chapter-hero-banner {
  height: 130px;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  margin-bottom: 14px;
  border: 1px solid var(--border-dark);
}

.chapter-hero-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chapter-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(15, 14, 17, 0.8) 100%);
  display: flex;
  align-items: flex-end;
  padding: 12px 16px;
}

.chapter-hero-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Section Jump Bar */
.section-jump-container {
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 8px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

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

.section-jump-bar {
  display: inline-flex;
  gap: 6px;
}

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

.jump-pill:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

/* Passages List */
.passages-list {
  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(255, 112, 67, 0.35);
}

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

.passage-sec-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--primary);
  text-transform: uppercase;
}

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

.action-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.action-icon-btn:hover {
  color: var(--primary-light);
  background: rgba(255, 112, 67, 0.1);
}

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

/* 3. Search View */
.search-box-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.search-field {
  width: 100%;
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 12px 14px 12px 42px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.search-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255, 112, 67, 0.2);
}

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

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

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

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

.concept-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.concept-chip.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: 700;
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 4. Settings View */
.settings-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

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

.settings-text h3 {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 3px;
}

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

.btn-pill-small {
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

/* Bottom Navigation */
.app-bottom-nav {
  height: 60px;
  background: rgba(24, 23, 30, 0.98);
  border-top: 1px solid var(--border-dark);
  display: flex;
  justify-content: space-around;
  align-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

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

.nav-tab:hover {
  color: var(--text-primary);
}

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

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

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

.reader-chapter-title {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-light);
}

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

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

.reader-prose {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-primary);
  text-align: left;
  user-select: text;
  -webkit-user-select: text;
}

.reader-nav-footer {
  height: 60px;
  border-top: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}


.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);
}
