/* ==========================================================================
   StudyWithMe — Design tokens (xem CLAUDE.md > Design System)
   ========================================================================== */
:root {
  --color-tan: #C1B676;
  --color-olive: #6E665B;
  --color-navy: #0D121F;
  --color-paper: #E4E3E0;
  --color-ink: #1A1A17;
  --color-cream: #F5F2E9;

  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --max-width: 1180px;
  --gutter: clamp(1.25rem, 5vw, 4rem);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ol, ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p, blockquote { margin: 0; }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.75rem var(--gutter);
}
.logo {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-ink);
}
.logo-dot { color: var(--color-olive); }
.topnav { display: flex; gap: 2rem; }
.topnav a {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
  transition: opacity 0.3s var(--ease);
}
.topnav a:hover { opacity: 1; }

/* ==========================================================================
   Side nav (vertical, cạnh trái — gợi từ ảnh tham chiếu)
   ========================================================================== */
.side-nav {
  position: fixed;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  display: flex;
  gap: 2.25rem;
  z-index: 20;
  mix-blend-mode: difference;
}
.side-nav a {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  opacity: 0.55;
  transition: opacity 0.3s var(--ease);
}
.side-nav a:hover { opacity: 1; }

@media (max-width: 900px) {
  .side-nav { display: none; }
}

/* ==========================================================================
   Section base
   ========================================================================== */
.section {
  padding: 7rem var(--gutter) 5rem;
}
.section--tan { background: var(--color-tan); color: var(--color-ink); }
.section--olive { background: var(--color-olive); color: var(--color-cream); }
.section--dark { background: var(--color-navy); color: var(--color-cream); }
.section--paper { background: var(--color-paper); color: var(--color-ink); }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 1rem;
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}
.eyebrow--light { color: var(--color-cream); opacity: 0.6; }

.section-head {
  max-width: var(--max-width);
  margin: 0 auto 3.5rem;
  text-align: left;
}
.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3.2vw, 2.75rem);
  font-weight: 500;
  line-height: 1.2;
  max-width: 32ch;
}
.section-title--light { color: var(--color-cream); }

/* ==========================================================================
   Hero / Overview
   ========================================================================== */
.hero-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-top: 3rem;
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: clamp(2.5rem, 6vw, 6rem);
  align-items: start;
}

.book-cover {
  perspective: 1000px;
}
.book-cover__frame {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 2px;
  background: radial-gradient(120% 120% at 50% 20%, #262a33 0%, var(--color-navy) 65%);
  box-shadow: 26px 34px 55px -24px rgba(13, 18, 26, 0.55);
  color: var(--color-cream);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  transform: rotateY(-14deg) rotateX(1deg);
  transform-origin: center left;
  transition: transform 0.5s var(--ease);
}
.book-cover__frame::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 0;
  bottom: 3px;
  width: 5px;
  background: repeating-linear-gradient(
    to bottom,
    #e7e3d6 0px, #e7e3d6 2px,
    #cfcabb 2px, #cfcabb 3px
  );
  box-shadow: -1px 0 3px rgba(0, 0, 0, 0.3) inset;
}
.book-cover__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--color-cream);
  opacity: 0.9;
}
.book-cover__text {
  position: relative;
  z-index: 1;
  padding: 1.75rem;
}
.book-cover__title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}
.book-cover__author {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}
.book-cover__caption {
  margin-top: 0.9rem;
  font-size: 0.75rem;
  opacity: 0.6;
}

.hero-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.75rem, 6vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
}
.hero-subtitle {
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 46ch;
  opacity: 0.85;
  margin-bottom: 2rem;
}

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  border-top: 1px solid rgba(26, 26, 23, 0.18);
  border-bottom: 1px solid rgba(26, 26, 23, 0.18);
}
.meta-item {
  padding: 1.1rem 1.75rem 1.1rem 0;
  margin-right: 1.75rem;
  border-right: 1px solid rgba(26, 26, 23, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.meta-item:last-child { border-right: none; margin-right: 0; }
.meta-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
}
.meta-value {
  font-family: var(--font-serif);
  font-size: 1.15rem;
}

.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 2.5rem; }
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  transition: all 0.3s var(--ease);
}
.btn--primary {
  background: var(--color-ink);
  color: var(--color-cream);
}
.btn--primary:hover { background: #000; transform: translateY(-1px); }
.btn--ghost {
  border: 1px solid rgba(26, 26, 23, 0.35);
  color: var(--color-ink);
}
.btn--ghost:hover { border-color: var(--color-ink); background: rgba(26,26,23,0.05); }

.author-block {
  max-width: var(--max-width);
  margin: 5.5rem auto 0;
  padding-top: 3rem;
  border-top: 1px solid rgba(26, 26, 23, 0.18);
  max-width: 62ch;
}
.author-bio { font-size: 1rem; line-height: 1.75; opacity: 0.85; }

/* ==========================================================================
   Quotes
   ========================================================================== */
.quote-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: clamp(1.5rem, 3vw, 3rem);
  row-gap: 3rem;
  padding-top: 3rem;
  border-top: 1px solid rgba(245, 242, 233, 0.14);
}
.quote-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.quote-mark {
  font-family: var(--font-serif);
  font-size: 3rem;
  line-height: 1;
  color: var(--color-cream);
  opacity: 0.5;
}
.quote-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.55;
  font-weight: 400;
}
.quote-source {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 1.1rem;
}
.quote-source::before {
  content: "";
  display: block;
  width: 1.5rem;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
  margin-bottom: 0.3rem;
}
.quote-chapter {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.quote-chapter-title {
  font-size: 0.78rem;
  opacity: 0.6;
}

@media (max-width: 960px) {
  .quote-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .quote-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Chapters / TOC
   ========================================================================== */
.chapter-list {
  max-width: var(--max-width);
  margin: 0 auto;
  border-top: 1px solid rgba(245, 242, 233, 0.15);
}
.chapter-item {
  display: grid;
  grid-template-columns: 3.5rem 1fr 2rem;
  align-items: baseline;
  gap: 1.5rem;
  padding: 1.85rem 0;
  border-bottom: 1px solid rgba(245, 242, 233, 0.15);
  transition: background 0.3s var(--ease);
}
.chapter-item:hover { background: rgba(245, 242, 233, 0.04); }
.chapter-num {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  opacity: 0.5;
}
.chapter-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}
.chapter-summary {
  font-size: 0.95rem;
  line-height: 1.6;
  opacity: 0.7;
  max-width: 62ch;
}
.chapter-link {
  font-size: 1.1rem;
  opacity: 0.4;
  justify-self: end;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.chapter-item:hover .chapter-link { opacity: 1; transform: translateX(4px); }

@media (max-width: 640px) {
  .chapter-item {
    grid-template-columns: 2.5rem 1fr;
  }
  .chapter-link { display: none; }
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--color-paper);
  padding: 4.5rem var(--gutter) 2.5rem;
}
.footer-top {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid rgba(26, 26, 23, 0.15);
}
.footer-tagline { font-size: 0.95rem; opacity: 0.65; }
.footer-bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-top: 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  opacity: 0.6;
}
.footer-links { display: flex; gap: 1.5rem; }

/* ==========================================================================
   Add-book upload feature
   ========================================================================== */
.add-book-desc {
  font-size: 1.02rem;
  line-height: 1.65;
  max-width: 56ch;
  opacity: 0.8;
  margin-top: 1rem;
}

.upload-panel {
  max-width: var(--max-width);
  margin: 0 auto;
}

.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-align: center;
  padding: 3.5rem 2rem;
  border: 1px dashed rgba(26, 26, 23, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.upload-drop:hover,
.upload-drop.is-dragover {
  border-color: var(--color-ink);
  background: rgba(26, 26, 23, 0.03);
}
.upload-icon {
  width: 28px;
  height: 28px;
  opacity: 0.6;
  margin-bottom: 0.4rem;
}
.upload-drop__title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
}
.upload-drop__sub {
  font-size: 0.82rem;
  opacity: 0.6;
}

.upload-status {
  margin-top: 1.25rem;
  font-size: 0.88rem;
  opacity: 0.75;
  min-height: 1.3em;
}
.upload-status.is-error { color: #8a3b2e; opacity: 1; }

.upload-result {
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid rgba(26, 26, 23, 0.15);
}
.upload-result__title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.upload-result__meta {
  font-size: 0.88rem;
  opacity: 0.6;
}

.upload-chapters {
  margin-top: 2rem;
}
.upload-chapter-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid rgba(26, 26, 23, 0.12);
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1.25rem;
}
.upload-chapter-num {
  font-family: var(--font-serif);
  opacity: 0.5;
}
.upload-chapter-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}
.upload-chapter-summary {
  font-size: 0.92rem;
  line-height: 1.6;
  opacity: 0.75;
  margin-bottom: 0.6rem;
}
.upload-chapter-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  opacity: 0.85;
  border-left: 2px solid rgba(26, 26, 23, 0.25);
  padding-left: 0.85rem;
}

.upload-figures { margin-top: 2.5rem; }
.upload-figures__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.upload-figures__grid img {
  width: 100%;
  border: 1px solid rgba(26, 26, 23, 0.15);
  border-radius: 2px;
}

@media (max-width: 640px) {
  .upload-chapter-item { grid-template-columns: 2rem 1fr; }
  .upload-drop { padding: 2.5rem 1.25rem; }
}

/* ==========================================================================
   Contact form
   ========================================================================== */
.contact-panel {
  max-width: 640px;
  margin: 0 auto;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
/* Author CSS on .contact-form always beats the UA [hidden] rule regardless of
   specificity (origin/importance is resolved before specificity in the
   cascade), so form.hidden = true would otherwise have no visual effect. */
.contact-form[hidden] {
  display: none;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.form-field label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
}
.form-field input,
.form-field textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(26, 26, 23, 0.3);
  padding: 0.6rem 0;
  resize: vertical;
  transition: border-color 0.3s var(--ease);
}
.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-ink);
}

#contact-submit {
  align-self: flex-start;
  border: none;
  cursor: pointer;
}
#contact-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.contact-status {
  font-size: 0.88rem;
  opacity: 0.75;
  min-height: 1.3em;
}
.contact-status.is-error { color: #8a3b2e; opacity: 1; }

.contact-success h3 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}
.contact-success p {
  font-size: 0.95rem;
  line-height: 1.6;
  opacity: 0.8;
}
.contact-success a { text-decoration: underline; }

/* ==========================================================================
   Scroll reveal animation
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html { scroll-behavior: auto; }
}

/* ==========================================================================
   Responsive — mobile
   ========================================================================== */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .book-cover { max-width: 220px; }
}

@media (max-width: 480px) {
  .topnav { display: none; }
}

@media (max-width: 600px) {
  .topbar { padding: 1.25rem 1.25rem; }
  .topnav { gap: 1.25rem; }
  .section { padding: 6rem 1.25rem 3.5rem; }
  .meta-bar { flex-direction: column; }
  .meta-item {
    border-right: none;
    border-bottom: 1px solid rgba(26, 26, 23, 0.18);
    margin-right: 0;
    padding: 0.9rem 0;
  }
  .meta-item:last-child { border-bottom: none; }
}
