/* ============================================================
   WriteOps Press — Main Stylesheet
   Typography-first, minimal, classy.
   ============================================================ */

/* ----------------------------------------------------------
   0. CSS Custom Properties
   ---------------------------------------------------------- */
:root {
  /* Palette */
  --color-bg:         #FAFAFA;
  --color-bg-alt:     #F3F3F3;
  --color-text:       #111111;
  --color-text-muted: #666666;
  --color-border:     #E6E6E6;
  --color-white:      #FFFFFF;

  /* Pen accent (overridden per pen page via inline style) */
  --pen-accent: #111111;

  /* Typography */
  --font-sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Libre Baskerville', Georgia, serif;

  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1.0625rem; /* 17px */
  --text-lg:   1.25rem;   /* 20px */
  --text-xl:   1.5rem;    /* 24px */
  --text-2xl:  2rem;      /* 32px */
  --text-3xl:  2.75rem;   /* 44px */
  --text-4xl:  3.5rem;    /* 56px */

  --leading-tight:  1.2;
  --leading-normal: 1.6;
  --leading-loose:  1.8;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --max-width:    1140px;
  --radius:       4px;
  --radius-lg:    8px;

  /* Transitions */
  --transition: 200ms ease;
}

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

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--pen-accent);
  text-decoration: none;
  transition: opacity var(--transition);
}

a:hover { opacity: 0.75; }

ul, ol { list-style: none; }

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

/* ----------------------------------------------------------
   2. Layout Utilities
   ---------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.section {
  padding-block: var(--space-16);
}

.section--sm {
  padding-block: var(--space-8);
}

.section--lg {
  padding-block: var(--space-24);
}

/* ----------------------------------------------------------
   3. Typography
   ---------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: var(--leading-tight);
  font-weight: 700;
  color: var(--color-text);
}

h1 { font-size: clamp(var(--text-2xl), 5vw, var(--text-4xl)); }
h2 { font-size: clamp(var(--text-xl), 3.5vw, var(--text-3xl)); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); font-family: var(--font-sans); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

.text-muted  { color: var(--color-text-muted); }
.text-sm     { font-size: var(--text-sm); }
.text-center { text-align: center; }

.serif { font-family: var(--font-serif); }

/* ----------------------------------------------------------
   4. Buttons
   ---------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius);
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background-color: var(--pen-accent);
  color: var(--color-white);
  border: 2px solid var(--pen-accent);
}

.btn-primary:hover {
  opacity: 0.85;
  color: var(--color-white);
}

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

.btn-outline:hover {
  background-color: var(--color-text);
  color: var(--color-white);
}

.btn-ghost {
  background-color: transparent;
  color: var(--pen-accent);
  border: 2px solid var(--pen-accent);
}

.btn-ghost:hover {
  background-color: var(--pen-accent);
  color: var(--color-white);
}

/* ----------------------------------------------------------
   5. Header / Navigation
   ---------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-logo {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.logo-press { color: var(--color-text); }
.logo-name  { color: var(--color-text-muted); font-weight: 400; }

.primary-nav .nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  padding: var(--space-2) 0;
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: color var(--transition);
}

.nav-link:hover { color: var(--pen-accent); }
.nav-caret { font-size: 0.6em; }

/* Dropdown */
.nav-has-dropdown { position: relative; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: var(--space-2) 0;
  z-index: 200;
}

.nav-has-dropdown .dropdown-toggle[aria-expanded="true"] + .dropdown-menu {
  display: block;
}

.dropdown-link {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: background-color var(--transition), color var(--transition);
}

.dropdown-link::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--pen-accent);
  margin-right: var(--space-3);
  flex-shrink: 0;
}

.dropdown-link:hover {
  background-color: var(--color-bg-alt);
  color: var(--pen-accent);
  opacity: 1;
}

/* Mobile toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-text);
  transition: transform var(--transition), opacity var(--transition);
}

/* ----------------------------------------------------------
   6. Press Landing Page
   ---------------------------------------------------------- */
.press-hero {
  padding-block: var(--space-20);
  border-bottom: 1px solid var(--color-border);
}

.press-hero-inner {
  max-width: 680px;
}

.press-eyebrow {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.press-title {
  font-family: var(--font-serif);
  font-size: clamp(var(--text-3xl), 6vw, var(--text-4xl));
  line-height: var(--leading-tight);
  margin-bottom: var(--space-6);
}

.press-blurb {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: var(--leading-loose);
  max-width: 560px;
}

/* Pen name cards grid */
.pen-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-12);
}

.pen-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.pen-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--pen-accent);
}

.pen-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.07);
  border-color: var(--pen-accent);
}

.pen-card-name {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

.pen-card-promise {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}

.pen-card-link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--pen-accent);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.pen-card-link::after { content: ' →'; }

/* ----------------------------------------------------------
   7. Pen-Name Page
   ---------------------------------------------------------- */
.pen-hero {
  padding-block: var(--space-16);
  border-bottom: 1px solid var(--color-border);
}

.pen-hero-inner {
  max-width: 680px;
}

.pen-rule {
  display: block;
  width: 48px;
  height: 3px;
  background-color: var(--pen-accent);
  margin-bottom: var(--space-6);
  border-radius: 2px;
}

.pen-name {
  font-family: var(--font-serif);
  font-size: clamp(var(--text-2xl), 5vw, var(--text-3xl));
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.pen-promise {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: var(--leading-loose);
  margin-bottom: var(--space-4);
}

.content-notes-link { margin-top: var(--space-2); }
.subtle-link {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.subtle-link:hover { color: var(--color-text); opacity: 1; }

/* Section headings */
.section-heading {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.section-heading::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 40px;
  height: 2px;
  background-color: var(--pen-accent);
}

/* ----------------------------------------------------------
   8. Book Grid + Tiles
   ---------------------------------------------------------- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-8);
}

.book-tile {
  display: flex;
  flex-direction: column;
}

.book-tile--featured {
  grid-column: span 1;
}

.book-cover-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background-color: var(--color-bg-alt);
  margin-bottom: var(--space-4);
}

.book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.book-tile:hover .book-cover {
  transform: scale(1.03);
}

.book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  text-align: center;
  background: linear-gradient(135deg, var(--color-bg-alt), var(--color-border));
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-style: italic;
}

.book-info { flex: 1; display: flex; flex-direction: column; }

.book-series {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pen-accent);
  margin-bottom: var(--space-1);
}

.book-title {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.book-hook {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
  flex: 1;
}

.buy-btn {
  align-self: flex-start;
  margin-top: auto;
}

/* Featured books row */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-8);
  margin-bottom: var(--space-16);
}

/* ----------------------------------------------------------
   9. Buy Modal
   ---------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] { display: none; }

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

.modal-dialog {
  position: relative;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  width: min(480px, calc(100vw - 2rem));
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: modal-in 200ms ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.modal-book-title {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  line-height: var(--leading-tight);
}

.modal-close {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0 var(--space-1);
  transition: color var(--transition);
}

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

.modal-body {
  padding: var(--space-6);
}

.modal-subhead {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.store-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.store-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-white);
  transition: background-color var(--transition), border-color var(--transition);
  text-decoration: none;
}

.store-btn:hover {
  background-color: var(--color-bg-alt);
  border-color: var(--pen-accent);
  color: var(--pen-accent);
  opacity: 1;
}

.store-btn-label { font-weight: 600; }
.store-btn-flag  { font-size: var(--text-lg); }

/* ----------------------------------------------------------
   10. Newsletter page + CTA
   ---------------------------------------------------------- */
.newsletter-page-inner {
  max-width: 540px;
  margin-inline: auto;
  text-align: center;
}

.newsletter-page-inner h1 {
  margin-bottom: var(--space-4);
}

.newsletter-page-inner .lead {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.pen-newsletter-cta {
  background-color: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding-block: var(--space-8);
}

.newsletter-cta-inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.newsletter-cta-text {
  flex: 1;
  font-size: var(--text-base);
  margin-bottom: 0;
}

/* ----------------------------------------------------------
   11. Content notes
   ---------------------------------------------------------- */
.content-notes {
  background-color: var(--color-bg-alt);
  border-left: 3px solid var(--pen-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-4) var(--space-6);
  margin-block: var(--space-8);
}

.content-notes-title {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.content-notes p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: 0;
}

/* ----------------------------------------------------------
   12. Contact + Privacy pages
   ---------------------------------------------------------- */
.prose-page {
  max-width: 680px;
  padding-block: var(--space-16);
}

.prose-page h1 {
  margin-bottom: var(--space-6);
}

.prose-page h2 {
  font-size: var(--text-xl);
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
}

.prose-page p,
.prose-page ul,
.prose-page ol {
  margin-bottom: var(--space-4);
  line-height: var(--leading-loose);
}

.prose-page ul { list-style: disc; padding-left: var(--space-6); }
.prose-page ol { list-style: decimal; padding-left: var(--space-6); }
.prose-page li { margin-bottom: var(--space-2); }

.prose-page a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Contact form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-input,
.form-textarea {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-white);
  transition: border-color var(--transition);
  width: 100%;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--pen-accent);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.form-textarea {
  min-height: 140px;
  resize: vertical;
}

/* ----------------------------------------------------------
   13. Footer
   ---------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-20);
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-12);
  padding-block: var(--space-12);
  align-items: start;
}

.footer-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.footer-nav {
  display: flex;
  gap: var(--space-12);
}

.footer-col { min-width: 120px; }

.footer-heading {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.footer-col ul { display: flex; flex-direction: column; gap: var(--space-2); }

.footer-col a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: color var(--transition);
}

.footer-col a:hover { color: var(--color-text); opacity: 1; }

.footer-newsletter {
  max-width: 220px;
}

.footer-newsletter p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.footer-legal {
  background-color: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-4);
}

.footer-legal p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: 0;
}

.footer-legal a { color: var(--color-text-muted); text-decoration: underline; }

/* ----------------------------------------------------------
   14. Utility classes
   ---------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-block: var(--space-12);
}

/* ----------------------------------------------------------
   15. Responsive — Tablet
   ---------------------------------------------------------- */
@media (max-width: 900px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* ----------------------------------------------------------
   16. Responsive — Mobile
   ---------------------------------------------------------- */
@media (max-width: 600px) {
  :root {
    --text-base: 1rem;
  }

  .container {
    padding-inline: var(--space-4);
  }

  /* Mobile nav */
  .nav-toggle {
    display: flex;
  }

  .primary-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-4) var(--space-6) var(--space-6);
  }

  .primary-nav.is-open {
    display: block;
  }

  .primary-nav .nav-list {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .nav-item {
    width: 100%;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-link {
    width: 100%;
    padding: var(--space-4) 0;
    font-size: var(--text-base);
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0 0 var(--space-2) var(--space-4);
    display: block;
  }

  .site-header {
    position: relative;
  }

  .pen-cards-grid {
    grid-template-columns: 1fr;
  }

  .books-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .footer-nav {
    flex-direction: column;
    gap: var(--space-6);
  }

  .footer-newsletter {
    max-width: 100%;
  }

  .newsletter-cta-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .press-hero,
  .pen-hero {
    padding-block: var(--space-12);
  }
}

/* ----------------------------------------------------------
   17. Pen accent tints (applied via JS-injected class or inline)
   ---------------------------------------------------------- */
.pen-ash-wilder    { --pen-accent: #7A1E2C; }
.pen-nyx-montreaux { --pen-accent: #1C3F5E; }
.pen-rook-brennan  { --pen-accent: #2B5D3F; }
.pen-clay-daintry  { --pen-accent: #6B4A2B; }
.pen-jay-mcgilvery { --pen-accent: #1E4E7A; }
.pen-rita-dole     { --pen-accent: #4B2A63; }
