:root {
  --paper: #f6f1e6;
  --paper-card: #fbf8f1;
  --ink: #2a2117;
  --ink-dim: rgba(42, 33, 23, 0.62);
  --ink-line: rgba(42, 33, 23, 0.14);
  --purple: #5b2c6b;
  --gold: #c9a45c;
  --serif-he: 'Frank Ruhl Libre', serif;
  --serif-en: 'Cormorant Garamond', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: var(--serif-en);
}

::selection {
  background: var(--purple);
  color: var(--paper);
}

/* subtle aged-paper texture */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 6vw;
  background: var(--ink);
}

.nav-wordmark {
  display: block;
  text-decoration: none;
}

.nav-wordmark img {
  display: block;
  height: 1.3rem;
  width: auto;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.btn {
  display: inline-block;
  font-family: var(--serif-en);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-ghost {
  background: none;
  border: none;
  padding: 0.6rem 0.3rem;
  color: rgba(246, 241, 230, 0.75);
}

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

.btn-solid {
  background: var(--paper);
  border: 1px solid var(--paper);
  color: var(--ink);
  font-weight: 600;
}

.btn-solid:hover {
  opacity: 0.8;
}

/* .btn-solid (paper fill) only has contrast against the dark nav —
   this is the counterpart for buttons that sit on the light parchment
   body instead (subscribe modal, contact form submit). */
.btn-dark {
  background: var(--purple);
  border: 1px solid var(--purple);
  color: var(--paper);
  font-weight: 600;
}

.btn-dark:hover {
  opacity: 0.85;
}

/* hero */
.hero {
  width: 100%;
  padding: 9vh 8vw 6vh;
  text-align: center;
}

.hero-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 1rem;
}

.hero-tagline {
  font-size: clamp(1.3rem, 2.6vw, 1.8rem);
  font-style: italic;
  color: var(--ink-dim);
  max-width: 30ch;
  margin: 0 auto;
  line-height: 1.4;
}

/* quiet entry point to /trailer/ — deliberately a text link, not a thumbnail,
   so the hero stays as spare as the rest of the page */
.hero-trailer-link {
  display: inline-block;
  margin-top: 1.8rem;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--purple);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.hero-trailer-link:hover {
  border-bottom-color: var(--purple);
}

/* sort tabs above the story grid — toggles releaseOrder/chronoOrder/book */
.story-sort {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 6vw;
  display: flex;
  justify-content: center;
  gap: 2.2rem;
  margin-bottom: 3.5vh;
}

.story-sort-tab {
  background: none;
  border: none;
  font-family: var(--serif-en);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.story-sort-tab:hover {
  color: var(--gold);
}

.story-sort-tab.is-active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

/* mobile sort control — a single toggle button + dropdown menu, shown
   instead of the tab row below the mobile breakpoint (see media query) */
.story-sort-mobile {
  display: none;
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto 3.5vh;
  padding: 0 6vw;
  justify-content: center;
}

.story-sort-mobile-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--paper-card);
  border: 1px solid var(--ink-line);
  border-radius: 999px;
  font-family: var(--serif-en);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
  padding: 0.6rem 1.3rem;
  cursor: pointer;
}

.story-sort-mobile-caret {
  font-size: 0.7rem;
  color: var(--ink-dim);
}

.story-sort-mobile-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  background: var(--paper-card);
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  padding: 0.4rem;
  flex-direction: column;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(42, 33, 23, 0.12);
}

.story-sort-mobile-menu.open {
  display: flex;
}

.story-sort-mobile-menu button {
  background: none;
  border: none;
  font-family: var(--serif-en);
  font-size: 0.9rem;
  text-align: left;
  color: var(--ink);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}

.story-sort-mobile-menu button:hover {
  background: var(--paper);
}

.story-sort-mobile-menu button.is-active {
  color: var(--purple);
  font-weight: 500;
}

.story-book-heading {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--purple);
  border-bottom: 1px solid var(--ink-line);
  padding-bottom: 0.5rem;
  margin-top: 1.2rem;
}

.story-book-heading:first-child {
  margin-top: 0;
}

.story-book-heading-he {
  font-family: var(--serif-he);
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: normal;
  direction: rtl;
  unicode-bidi: isolate;
}

.story-eyebrow-he {
  font-family: var(--serif-he);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  direction: rtl;
  unicode-bidi: isolate;
}

/* story list — auto-fit so it grows from 2 to 3+ columns on its own as
   more stories are added, rather than a hardcoded column count */
.story-list {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 6vw 12vh;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.1rem;
}

.story-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  padding: 1.8rem 2rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.story-card:hover {
  border-color: var(--purple);
  transform: translateY(-1px);
}

.story-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 0.6rem;
}

.story-title {
  font-size: clamp(1.35rem, 2.6vw, 1.7rem);
  font-weight: 500;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.story-meta {
  font-size: 0.98rem;
  color: var(--ink-dim);
}

.story-title-he {
  font-family: var(--serif-he);
  direction: rtl;
  unicode-bidi: isolate;
}

/* site footer — dark band bookending the nav, homepage only */
.site-footer {
  background: var(--ink);
  padding: 6vh 6vw 4vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.6rem;
}

.site-footer-logo {
  height: 1.1rem;
  width: auto;
  opacity: 0.9;
}

.site-footer-links {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.site-footer-links a,
.site-footer-links button {
  font-family: var(--serif-en);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}

.site-footer-links a:hover,
.site-footer-links button:hover {
  color: var(--gold);
}

.site-footer-copyright {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
}

/* subscribe modal */
.subscribe-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6vw;
}

.subscribe-modal.open {
  display: flex;
}

.subscribe-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.subscribe-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  background: var(--paper-card);
  border-radius: 14px;
  padding: 2.6rem 2.4rem;
  text-align: center;
}

.subscribe-modal-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-dim);
  cursor: pointer;
}

.subscribe-modal-close:hover {
  color: var(--ink);
}

.subscribe-modal-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 0.8rem;
}

.subscribe-modal-title {
  font-family: var(--serif-en);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.3;
  margin-bottom: 1.6rem;
}

.subscribe-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.subscribe-input {
  font-family: var(--serif-en);
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--ink-line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.subscribe-input:focus {
  outline: none;
  border-color: var(--purple);
}

.subscribe-submit {
  width: 100%;
}

.subscribe-form-status {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--ink-dim);
  min-height: 1.2em;
}

.subscribe-form-status.error {
  color: #a33;
}

.subscribe-form-status.success {
  color: var(--purple);
}

/* contact modal */
.contact-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 6vw;
  overflow-y: auto;
}

.contact-modal.open {
  display: flex;
}

.contact-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.contact-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  background: var(--paper-card);
  border-radius: 14px;
  padding: 2.6rem 2.4rem;
}

.contact-modal-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-dim);
  cursor: pointer;
}

.contact-modal-close:hover {
  color: var(--ink);
}

.contact-modal-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 0.8rem;
}

.contact-modal-title {
  font-family: var(--serif-en);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.3;
  margin-bottom: 1.6rem;
}

/* contact page (standalone fallback at /contact/) */
.contact-nav-actions {
  display: flex;
}

.contact-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10vh 6vw 12vh;
}

.contact-card {
  max-width: 560px;
  width: 100%;
}

.contact-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 1rem;
}

.contact-title {
  font-family: var(--serif-en);
  font-weight: 500;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  margin-bottom: 1rem;
}

.contact-sub {
  color: var(--ink-dim);
  font-size: 1.05rem;
  line-height: 1.5;
  margin-bottom: 2.4rem;
  max-width: 46ch;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.contact-label {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 1rem;
}

.contact-label:first-child {
  margin-top: 0;
}

.contact-input {
  font-family: var(--serif-en);
  font-size: 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--ink-line);
  border-radius: 8px;
  background: var(--paper-card);
  color: var(--ink);
}

.contact-input:focus {
  outline: none;
  border-color: var(--purple);
}

textarea.contact-input {
  resize: vertical;
}

.contact-submit {
  margin-top: 1.4rem;
  align-self: flex-start;
}

.contact-form-status {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--ink-dim);
  min-height: 1.2em;
}

.contact-form-status.error {
  color: #a33;
}

.contact-form-status.success {
  color: var(--purple);
}

@media (max-width: 720px) {
  .story-list { grid-template-columns: 1fr; }
  .story-sort { display: none; }
  .story-sort-mobile { display: flex; }
}

@media (max-width: 640px) {
  .nav { padding: 1.1rem 5vw; }
  .nav-wordmark img { height: 1.1rem; }
  .btn { padding: 0.6rem 1rem; font-size: 0.72rem; }

  .hero { padding: 6vh 6vw 4vh; }
  .story-card { padding: 1.4rem 1.5rem; }
}
