/* ==========================================================================
   S. A. Røed — Author Website
   ========================================================================== */

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

:root {
  --bg: #08080c;
  --bg-elevated: #0d0d12;
  --ink: #f0ede6;
  --ink-muted: rgba(240, 237, 230, 0.72);
  --ink-subtle: rgba(240, 237, 230, 0.48);
  --accent: #c9a961;
  --accent-muted: rgba(201, 169, 97, 0.7);
  --border: rgba(240, 237, 230, 0.08);
  --border-accent: rgba(201, 169, 97, 0.25);

  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: 6rem;

  --max-width: 1100px;
  --content-width: 640px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* scroll-behavior: smooth removed - causes jank with sticky elements */

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Ambient Background
   ========================================================================== */

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.ambient::before {
  content: '';
  position: absolute;
  width: 140%;
  height: 140%;
  top: -20%;
  left: -20%;
  background:
    radial-gradient(ellipse 800px 600px at 30% 20%, rgba(201, 169, 97, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 600px 500px at 70% 60%, rgba(201, 169, 97, 0.03) 0%, transparent 70%),
    radial-gradient(ellipse 900px 400px at 50% 90%, rgba(201, 169, 97, 0.025) 0%, transparent 70%);
  animation: drift 120s ease-in-out infinite alternate;
}

.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 100% 80% at 50% 30%, transparent 0%, var(--bg) 70%);
}

@keyframes drift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(2%, 1%) rotate(1deg); }
}

/* ==========================================================================
   Skip Link (Accessibility)
   ========================================================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 1000;
}

.skip-link:focus {
  top: var(--space-sm);
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-lg);
  }
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: var(--space-sm) 0;
  background: rgba(8, 8, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.nav-brand {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-brand:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: var(--space-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: color var(--transition-fast);
}

.nav-link:hover,
.nav-link:focus {
  color: var(--ink);
}

.nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.nav-link[aria-current="page"] {
  color: var(--ink);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.875rem 1.5rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: #d4b46a;
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border-accent);
}

.btn-secondary:hover {
  background: rgba(201, 169, 97, 0.1);
  border-color: var(--accent-muted);
}

/* ==========================================================================
   Hero (Index Page)
   ========================================================================== */

.hero {
  padding: var(--space-xl) 0;
  min-height: 50vh;
  display: flex;
  align-items: center;
}

@media (min-width: 768px) {
  .hero {
    min-height: 60vh;
  }
}

.hero-inner {
  display: grid;
  gap: var(--space-xl);
  align-items: center;
}

@media (min-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr 300px;
    gap: var(--space-2xl);
  }
}

.hero-content {
  max-width: var(--content-width);
}

.hero-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.hero-title {
  margin: 0 0 var(--space-md);
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-description {
  margin: 0 0 var(--space-lg);
  font-size: 1.125rem;
  color: var(--ink-muted);
  max-width: 51ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

@media (max-width: 499px) {
  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Book Card (Index Hero) */
.book-card {
  position: relative;
  display: block;
  text-decoration: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition-base);
}

.book-card:hover {
  transform: translateY(-4px);
}

.book-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.book-card img {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.3),
    0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

@media (max-width: 899px) {
  .book-card {
    justify-self: center;
    order: -1;
  }

  .book-card img {
    max-width: 200px;
  }
}

/* ==========================================================================
   Hero (Book Page)
   ========================================================================== */

.hero--book {
  min-height: auto;
  padding: var(--space-xl) 0 var(--space-2xl);
}

.hero--book .hero-inner {
  align-items: stretch;
}

@media (min-width: 800px) {
  .hero--book .hero-inner {
    grid-template-columns: minmax(0, 1fr) 2fr;
  }
}

/* Book Cover */
.book-cover {
  justify-self: center;
  margin: 0;
}

.book-cover img {
  display: block;
  max-width: 200px;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.3),
    0 25px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

@media (min-width: 800px) {
  .book-cover {
    justify-self: center;
    display: flex;
    align-items: center;
  }

  .book-cover img {
    max-width: 100%;
    width: auto;
    height: 100%;
    max-height: 520px;
    object-fit: contain;
  }
}

@media (max-width: 799px) {
  .book-cover img {
    width: 100%;
    height: auto;
    max-width: 200px;
  }
}

/* Book Info */
.book-info {
  max-width: var(--content-width);
}

.book-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.book-title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.book-author {
  margin: 0 0 var(--space-md);
  font-size: 1.125rem;
  color: var(--ink-muted);
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.tag {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.book-description {
  margin: 0 0 var(--space-lg);
  color: var(--ink-muted);
  font-size: 1.0625rem;
  line-height: 1.7;
}

.book-description p {
  margin: 0;
}

.book-description p + p {
  margin-top: var(--space-sm);
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
  padding: var(--space-2xl) 0;
}

.section-header {
  margin-bottom: var(--space-lg);
}

.section-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Quote Section
   ========================================================================== */

.quote-section {
  border-top: 1px solid var(--border);
}

@media (max-width: 499px) {
  .quote-section {
    border-top: none;
  }
}

.quote-block {
  max-width: var(--content-width);
  border-left: 2px solid var(--border-accent);
  padding-left: var(--space-md);
}

.quote-text {
  margin: 0;
  font-size: clamp(1.125rem, 3vw, 1.5rem);
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-muted);
}

.quote-attribution {
  margin-top: var(--space-sm);
  padding-left: var(--space-md);
  font-size: 0.875rem;
  color: var(--ink-subtle);
}

/* Quotes Grid (Book Page) */
.quotes-grid {
  display: grid;
  gap: var(--space-lg);
  max-width: var(--content-width);
}

.quotes-grid .quote-block {
  max-width: none;
}

.quotes-grid .quote-text {
  font-size: 1.125rem;
  line-height: 1.55;
}

/* ==========================================================================
   Newsletter
   ========================================================================== */

.newsletter-section {
  border-top: 1px solid var(--border);
  text-align: center;
  padding-top: var(--space-lg);
}

@media (max-width: 499px) {
  .newsletter-section {
    border-top: none;
  }
}

.newsletter-content {
  max-width: 480px;
  margin: 0 auto;
}

.newsletter-invitation {
  margin: 0 0 var(--space-md);
  color: var(--ink-subtle);
  font-size: 0.9375rem;
}

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

@media (min-width: 500px) {
  .newsletter-form {
    flex-direction: row;
  }
}

.newsletter-input {
  flex: 1;
  padding: 0.875rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.newsletter-input::placeholder {
  color: var(--ink-subtle);
}

.newsletter-input:focus {
  outline: none;
  border-color: var(--accent-muted);
}

.newsletter-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
  text-align: center;
}

@media (min-width: 600px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

.footer-copyright {
  font-size: 0.875rem;
  color: var(--ink-subtle);
}

.footer-links {
  display: flex;
  gap: var(--space-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-link {
  color: var(--ink-subtle);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--ink);
}

.footer-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.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;
}
