/* ==========================================================================
   F. S. Dias — fsdias.com
   Literary author website. Typography-first, minimal, cinematic.
   ========================================================================== */

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 18.5px;
  line-height: 1.68;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; transition: color 180ms ease, opacity 180ms ease; }
a:hover { opacity: 0.72; }

button { font: inherit; background: none; border: none; cursor: pointer; color: inherit; }

/* ---------- Design tokens ---------- */
:root {
  --bg: #f7f4ee;
  --bg-deep: #efe6d5;
  --bg-warm: #f4ead4;
  --bg-cool: #e7edf1;
  --bg-card: #fbfaf6;
  --text: #14120f;
  --text-muted: #524940;
  --text-faint: #8d867b;
  --border: #e4ded2;
  --border-strong: #c9c2b3;
  --accent: #b5533a;
  --accent-dark: #8a3b26;
  --accent-soft: rgba(181, 83, 58, 0.10);
  --shadow-sm: 0 1px 2px rgba(26,26,26,0.04), 0 2px 8px rgba(26,26,26,0.05);
  --shadow-md: 0 4px 12px rgba(26,26,26,0.07), 0 12px 32px rgba(26,26,26,0.09);
  --shadow-lg: 0 12px 28px rgba(26,26,26,0.12), 0 28px 64px rgba(26,26,26,0.14);

  --serif: 'Cormorant Garamond', 'EB Garamond', 'Georgia', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --max-page: 1200px;
  --max-reading: 680px;
  --nav-h: 72px;

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

/* Series accent overrides (apply both as body class and as section class) */
.theme-shadow {
  --accent: #3f6280;
  --accent-dark: #2a465c;
  --accent-soft: rgba(63, 98, 128, 0.10);
}
.theme-hours {
  --accent: #a67a2f;
  --accent-dark: #7a561e;
  --accent-soft: rgba(166, 122, 47, 0.12);
}
.theme-whole {
  --accent: #7a3e3e;
  --accent-dark: #5a2a2a;
  --accent-soft: rgba(122, 62, 62, 0.10);
}

/* Colored backgrounds on home-page section themes (not on book-detail bodies) */
section.theme-shadow {
  background: linear-gradient(180deg, #eef3f6 0%, #dde6ec 100%);
}
section.theme-hours {
  background: linear-gradient(180deg, #f5ecd8 0%, #ecdcba 100%);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: var(--text);
}

.display {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.8rem, 7vw, 5.8rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.serif-italic {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
}

/* ---------- Layout helpers ---------- */
.container {
  max-width: var(--max-page);
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 48px);
}

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

section { padding: clamp(56px, 10vw, 128px) 0; }
@media (max-width: 480px) {
  section { padding: 48px 0; }
}

.divider {
  width: 40px;
  height: 1px;
  background: var(--border-strong);
  margin: 32px auto;
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 244, 238, 0.92);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 240ms ease, background 240ms ease;
}
.site-header.scrolled { border-bottom-color: var(--border); }

.nav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand:hover { opacity: 1; color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  font-size: 14px;
  letter-spacing: 0.04em;
}
.nav-links a { color: var(--text-muted); }
.nav-links a:hover { color: var(--text); opacity: 1; }

.lang-toggle {
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lang-toggle a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-muted);
}
.lang-toggle a.active {
  background: var(--text);
  color: var(--bg);
}

@media (max-width: 760px) {
  .nav-links { gap: 16px; font-size: 13px; }
  .lang-toggle { padding: 3px; }
  .lang-toggle a { padding: 5px 9px; font-size: 11px; }
}
@media (max-width: 480px) {
  .nav { gap: 12px; }
  .nav-links { gap: 12px; font-size: 12px; }
  .nav-links a { white-space: nowrap; }
  .brand { font-size: 1.2rem; }
  :root { --nav-h: 60px; }
}

/* ---------- Hero ---------- */
.hero {
  padding: clamp(72px, 14vh, 200px) 0 clamp(56px, 10vw, 128px);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 70%;
  height: 130%;
  background: radial-gradient(ellipse at center, rgba(181,83,58,0.14), transparent 65%);
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -15%;
  width: 55%;
  height: 100%;
  background: radial-gradient(ellipse at center, rgba(63,98,128,0.10), transparent 65%);
  pointer-events: none;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 900px;
}
.hero h1 .serif-italic {
  word-break: keep-all;
  overflow-wrap: break-word;
}
.hero h1 {
  font-size: clamp(2.8rem, 10vw, 7.5rem);
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.025em;
  margin-bottom: 24px;
}
.hero h1 .serif-italic {
  display: block;
  font-size: 0.45em;
  color: var(--text-muted);
  letter-spacing: 0;
  font-weight: 400;
  margin-top: 16px;
  line-height: 1.3;
}
.hero-lede {
  max-width: 560px;
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  line-height: 1.6;
  color: var(--text-muted);
  margin-top: 8px;
}

.scroll-hint {
  margin-top: clamp(40px, 8vw, 72px);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.scroll-hint::after {
  content: '';
  width: 40px;
  height: 1px;
  background: var(--text-faint);
  animation: scrollHint 2.4s ease-in-out infinite;
}
@keyframes scrollHint {
  0%, 100% { transform: scaleX(0.4); transform-origin: left; opacity: 0.5; }
  50% { transform: scaleX(1); opacity: 1; }
}

/* ---------- Series block ---------- */
.series-intro {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  max-width: 860px;
  margin: 0 auto clamp(48px, 8vw, 96px);
  text-align: center;
}
.series-intro h2 {
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -0.015em;
}
.series-intro .tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto;
}
.series-intro .description {
  max-width: 640px;
  margin: 0 auto;
  color: var(--text-muted);
}

/* ---------- Books grid ---------- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}
.books-grid.series-grid {
  grid-template-columns: repeat(5, 1fr);
}
.books-grid.standalone-grid {
  grid-template-columns: repeat(2, 1fr);
  max-width: 860px;
  margin: 0 auto;
  gap: clamp(32px, 6vw, 72px);
}

@media (max-width: 900px) {
  .books-grid.series-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (max-width: 640px) {
  .books-grid.standalone-grid { grid-template-columns: 1fr; gap: 48px; }
  .books-grid.series-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (max-width: 420px) {
  .books-grid.series-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  transition: transform 400ms var(--easing);
}
.book-card:hover { opacity: 1; }
.book-card:hover .book-cover { transform: translateY(-6px); }
.book-card:hover .book-cover::after { opacity: 1; }

.book-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: var(--shadow-md);
  transition: transform 500ms var(--easing), box-shadow 500ms var(--easing);
}
.book-cover:hover { box-shadow: var(--shadow-lg); }
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 700ms var(--easing);
}
.book-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.35));
  opacity: 0;
  transition: opacity 400ms ease;
}

.book-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.25;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.book-meta {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Standalone cards — larger, with tagline */
.standalone-grid .book-card { text-align: left; gap: 24px; }
.standalone-grid .book-cover { max-width: 280px; }
.standalone-grid .book-title { font-size: clamp(1.4rem, 3.5vw, 1.8rem); line-height: 1.1; }
.standalone-grid .book-tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.45;
}
@media (max-width: 640px) {
  .standalone-grid .book-card { text-align: center; align-items: center; }
  .standalone-grid .book-cover { max-width: 240px; }
}

/* ---------- Section heading ---------- */
.section-head {
  text-align: center;
  margin-bottom: clamp(40px, 8vw, 96px);
}
.section-head h2 {
  font-size: clamp(1.9rem, 5vw, 3.8rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 12px 0;
}
.section-head h2::after,
.series-intro h2::after {
  content: '';
  display: block;
  width: 56px;
  height: 2px;
  background: var(--accent);
  margin: 20px auto 0;
  border-radius: 2px;
}
.section-head p {
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.1rem);
}

/* ---------- Book detail page ---------- */
.book-hero {
  padding: clamp(40px, 8vw, 96px) 0 clamp(32px, 6vw, 64px);
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
}
@media (max-width: 820px) {
  .book-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 32px;
  }
  .book-hero-text { max-width: 560px; }
  .book-hero-cover { max-width: 280px; }
}

.book-hero-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  max-width: 420px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.book-hero-cover img { width: 100%; height: 100%; object-fit: cover; }

.book-hero-text .eyebrow { margin-bottom: 16px; display: inline-block; }
.book-hero-text h1 {
  font-size: clamp(2.1rem, 6.5vw, 4.6rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.book-hero-text .subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  color: var(--text-muted);
  margin-bottom: 24px;
}
.book-hero-text .tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  line-height: 1.5;
  color: var(--text);
  margin: clamp(20px, 4vw, 32px) 0 clamp(28px, 5vw, 40px);
  max-width: 520px;
}
@media (max-width: 820px) {
  .book-hero-text .tagline { margin-left: auto; margin-right: auto; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px;
  min-height: 48px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  transition: transform 220ms var(--easing), background 220ms ease, box-shadow 220ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  opacity: 1;
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn .arrow {
  transition: transform 220ms ease;
}
.btn:hover .arrow { transform: translateX(4px); }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn.ghost:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ---------- Description block ---------- */
.book-description {
  max-width: var(--max-reading);
  margin: 0 auto;
  padding: clamp(40px, 8vw, 96px) clamp(20px, 5vw, 48px);
  border-top: 1px solid var(--border);
}
.book-description p {
  margin-bottom: 1.4em;
  font-size: clamp(1.05rem, 1.7vw, 1.15rem);
  line-height: 1.78;
  color: var(--text);
}
.book-description p:first-child::first-line {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
}

/* ---------- Series strip (on book page) ---------- */
.series-strip {
  padding: clamp(48px, 8vw, 96px) 0;
  border-top: 1px solid var(--border);
  text-align: center;
}
.series-strip .eyebrow { margin-bottom: 16px; display: inline-block; }
.series-strip h3 {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 400;
  margin-bottom: clamp(28px, 5vw, 40px);
}
.series-covers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(12px, 2.5vw, 32px);
  max-width: 860px;
  margin: 0 auto;
}
@media (max-width: 640px) {
  .series-covers { grid-template-columns: repeat(5, 1fr); gap: 10px; }
}
@media (max-width: 420px) {
  .series-covers { grid-template-columns: repeat(5, 1fr); gap: 6px; }
}
.series-covers .mini-cover {
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 2px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: transform 300ms var(--easing), box-shadow 300ms var(--easing);
}
.series-covers .mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.series-covers .mini-cover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  opacity: 1;
}
.series-covers .mini-cover.current::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  pointer-events: none;
}
.series-covers .mini-title {
  display: block;
  font-family: var(--serif);
  font-size: 12px;
  margin-top: 10px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Also by ---------- */
.also-by {
  padding: clamp(48px, 8vw, 96px) 0;
  border-top: 1px solid var(--border);
  text-align: center;
}
.also-by h3 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 400;
  margin-bottom: 48px;
}

/* ---------- About page ---------- */
.about-hero {
  padding: clamp(64px, 14vw, 160px) 0 clamp(40px, 8vw, 96px);
  text-align: center;
}
.about-hero h1 {
  font-size: clamp(2.4rem, 8vw, 5.6rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}
.about-hero .tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.1rem, 2.5vw, 1.3rem);
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
}
.about-body {
  max-width: var(--max-reading);
  margin: 0 auto;
  padding: clamp(24px, 6vw, 72px) 0;
}
.about-body p {
  margin-bottom: 1.4em;
  font-size: clamp(1.05rem, 1.7vw, 1.15rem);
  line-height: 1.78;
}

.contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: clamp(28px, 5vw, 56px);
  text-align: center;
  max-width: 560px;
  margin: clamp(40px, 8vw, 80px) auto 0;
}
.contact-card .eyebrow { margin-bottom: 12px; }
.contact-card h3 {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 400;
  margin-bottom: 16px;
}
.contact-card a {
  font-family: var(--sans);
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  font-weight: 500;
  font-style: normal;
  letter-spacing: 0.01em;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 3px;
  word-break: break-word;
}
.contact-card a:hover { opacity: 1; color: var(--accent-dark); border-bottom-color: var(--accent-dark); }

/* ---------- Footer ---------- */
.site-footer {
  padding: clamp(48px, 8vw, 72px) 0 clamp(32px, 5vw, 48px);
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
  padding-bottom: calc(clamp(32px, 5vw, 48px) + env(safe-area-inset-bottom, 0px));
}
.footer-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
}
@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; text-align: center; justify-items: center; gap: 24px; }
}
.footer-brand {
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--text);
}
.footer-meta {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}
.footer-meta a { color: var(--accent); border-bottom: 1px solid transparent; transition: border-color 200ms ease; }
.footer-meta a:hover { opacity: 1; border-bottom-color: var(--accent); }
.footer-links {
  display: flex;
  gap: 24px;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-links a { padding: 6px 0; min-height: 32px; display: inline-flex; align-items: center; }
.footer-copy {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .footer-copy { justify-content: center; text-align: center; gap: 8px; }
}

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 900ms var(--easing), transform 900ms var(--easing);
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}
.reveal.delay-1 { transition-delay: 100ms; }
.reveal.delay-2 { transition-delay: 200ms; }
.reveal.delay-3 { transition-delay: 300ms; }
.reveal.delay-4 { transition-delay: 400ms; }

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

/* ---------- Root language detector ---------- */
.lang-root {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.lang-root-inner {
  text-align: center;
  max-width: 420px;
}
.lang-root h1 {
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 400;
  margin-bottom: 16px;
}
.lang-root p {
  color: var(--text-muted);
  margin-bottom: 32px;
}
.lang-root-links {
  display: flex;
  gap: 16px;
  justify-content: center;
}
