/* Farmando Aura — leitor estático */

:root {
  --bg-deep: #06080d;
  --bg-panel: #0c1018;
  --bg-elevated: #121822;
  --bg-hover: #1a2230;
  --text-primary: #e8ecf4;
  --text-secondary: #8b95a8;
  --text-muted: #5c6578;
  --accent: #5eead4;
  --accent-dim: #2dd4bf66;
  --accent-glow: #5eead422;
  --border: #1e2836;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --font-read: "Literata", Georgia, serif;
  --read-width: 54.6rem;
  --sidebar-width: 17rem;
  --toolbar-height: 3.25rem;
  --font-size: 1.125rem;
  --line-height: 1.75;
  --radius: 10px;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-glow), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, #6366f111, transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  display: flex;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.25rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.library-back {
  flex: 1 0 100%;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.library-back:hover {
  color: var(--accent);
}

.brand {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-glow {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-dim);
}

.brand-sub {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.chapter-index {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.index-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.35rem;
}

.chapter-link {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}

.chapter-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chapter-link.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.chapter-link .num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 1.5rem;
}

.chapter-link.active .num {
  color: var(--accent);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.aura-badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.download-bar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition),
    background var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
}

.download-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.download-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}

.download-btn:active {
  transform: translateY(0);
}

.download-btn.unavailable {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(1);
}

.download-btn::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--text-primary);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}

.download-btn:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.toolbar {
  height: var(--toolbar-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.toolbar-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}

.toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toolbar-library {
  display: none;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color var(--transition), border-color var(--transition);
}

.toolbar-library:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.toolbar-title {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-actions {
  display: flex;
  gap: 0.35rem;
}

.progress-track {
  height: 2px;
  background: var(--border);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.1s linear;
}

.content {
  flex: 1;
  padding: 2.5rem 1.5rem 3rem;
  max-width: calc(var(--read-width) + 3rem);
  margin: 0 auto;
  width: 100%;
}

/* Cover */
.cover {
  text-align: center;
  padding: 2rem 0 3rem;
}

.cover-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.cover-title {
  font-family: var(--font-read);
  font-size: clamp(2.5rem, 8vw, 3.75rem);
  font-weight: 600;
  line-height: 1.05;
  margin: 0 0 0.5rem;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cover-tagline {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 2.5rem;
  font-style: italic;
}

.cover-synopsis {
  text-align: left;
  font-family: var(--font-read);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text-secondary);
  border-left: 2px solid var(--accent-dim);
  padding-left: 1.25rem;
  margin: 0 auto 2.5rem;
  max-width: 36rem;
}

.cover-synopsis p {
  margin: 0 0 1rem;
}

.cover-synopsis p:last-child {
  margin-bottom: 0;
}

.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2.5rem;
}

.meta-tag {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.75rem;
  background: var(--accent);
  color: var(--bg-deep);
  border: none;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 0 32px var(--accent-glow);
}

.btn-start:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 48px var(--accent-dim);
}

/* Chapter reading */
.chapter-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.chapter-number {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.chapter-title {
  font-family: var(--font-read);
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.chapter-body {
  font-family: var(--font-read);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text-primary);
}

.chapter-body p {
  margin: 0 0 1.25rem;
  text-indent: 1.5em;
}

.chapter-body p:first-child {
  text-indent: 0;
}

.chapter-body p:first-child::first-letter {
  font-size: 3.2em;
  float: left;
  line-height: 0.85;
  margin: 0.05em 0.12em 0 0;
  color: var(--accent);
  font-weight: 600;
}

.chapter-body em {
  font-style: italic;
  color: var(--text-secondary);
}

.chapter-body strong {
  color: var(--accent);
  font-weight: 600;
}

.chapter-body .dialogue {
  margin: 1.25rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  text-indent: 0 !important;
  color: var(--text-secondary);
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
  max-width: calc(var(--read-width) + 3rem);
  margin: 0 auto;
  width: 100%;
}

.nav-btn {
  padding: 0.65rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

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

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

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

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

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #00000088;
  z-index: 20;
}

/* Mobile */
@media (max-width: 768px) {
  .toolbar-library {
    display: inline-flex;
    align-items: center;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
  }

  .overlay[hidden] {
    display: none;
  }

  .overlay:not([hidden]) {
    display: block;
  }

  .content {
    padding: 1.75rem 1.25rem 2.5rem;
  }
}
