/* =========================================================
   WRITING SECTION — flash-fiction reading experience
   Reskinned onto the shared portfolio design system (css/styles.css).
   Tokens/fonts/reset live in styles.css; this file is writing-only and
   scoped under body.writing so it can't leak onto other pages.
   Organization: layout shell -> shared prose rhythm -> index list ->
   story article -> media queries (min-width 48rem / 64rem, mobile-first)
   ========================================================= */

/* ===== LAYOUT SHELL =====
   Mobile-first base; scaled up at the 48rem breakpoint below. */
.writing-page {
  padding: var(--space-xl) var(--space-md) var(--space-4xl);
}

.writing-index,
.story {
  /* Comfortable reading measure, capped so it never outgrows the viewport
     on narrow screens. */
  max-width: min(65ch, 100%);
  margin: 0 auto;
}

/* ===== SHARED PROSE RHYTHM ===== */
.writing-index p,
.story p {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.75;
  color: var(--color-text-secondary);
  margin-block-end: var(--space-lg);
}

.writing-index p:last-child,
.story p:last-child {
  margin-block-end: 0;
}

.writing-index a,
.story a {
  color: var(--color-primary-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--color-primary-ring);
  transition: border-bottom-color var(--transition), color var(--transition), text-decoration-color var(--transition);
}

.writing-index a:hover,
.writing-index a:focus-visible,
.story a:hover,
.story a:focus-visible {
  color: var(--color-primary-ink);
  border-bottom-color: var(--color-primary-ink);
  text-decoration: underline;
}

/* ===== INDEX PAGE ===== */
.writing-index__title {
  font-family: var(--font-display);
  font-size: var(--type-display-md);
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  margin-block-end: var(--space-xl);
}

.writing-index > p {
  font-size: var(--font-size-base);
  margin-block-end: var(--space-2xl);
}

/* Story list rendered as a clean, scannable list of links rather than
   default bulleted <ul> markup. */
.writing-index ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.writing-index li {
  border-bottom: 1px solid var(--color-border);
}

.writing-index li:last-child {
  border-bottom: none;
}

.writing-index a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: none;
  transition: color var(--transition), padding-inline-start var(--transition);
}

.writing-index a::after {
  content: "→";
  color: var(--color-primary);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.writing-index a:hover,
.writing-index a:focus-visible {
  color: var(--color-primary-ink);
  padding-inline-start: var(--space-sm);
}

.writing-index a:hover::after,
.writing-index a:focus-visible::after {
  transform: translateX(4px);
}

/* ===== STORY PAGE ===== */
.story__title {
  font-family: var(--font-display);
  font-size: var(--type-display-md);
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  margin-block-end: var(--space-xl);
}

/* Italic intro line — the author's note that precedes the <hr> rule. */
.story > p:first-of-type:has(em:only-child) {
  font-size: var(--font-size-lg);
  font-style: italic;
  color: var(--color-text-muted);
  line-height: 1.65;
}

.story hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-2xl) 0;
}

.story p {
  font-size: var(--font-size-base);
  line-height: 1.85;
}

/* ===== RESPONSIVE — small-mobile-landscape and up (min-width 30rem / 480px) ===== */
@media (min-width: 30rem) {
  .story__title,
  .writing-index__title {
    font-size: var(--type-display-lg);
  }

  .writing-index > p {
    font-size: var(--font-size-lg);
  }
}

/* ===== RESPONSIVE — tablets and up (min-width 48rem / 768px) ===== */
@media (min-width: 48rem) {
  .writing-page {
    padding: var(--space-2xl) var(--space-lg) var(--space-5xl);
  }

  .writing-index a {
    font-size: var(--font-size-lg);
  }
}

/* ===== FOOTER ALIGNMENT =====
   The shared footer (.site-footer, css/styles.css) pads horizontally with
   var(--gutter) and centers a 72rem .container inside it, but the writing
   section's prose runs in a narrower 65ch column inset by .writing-page's
   own padding instead. Re-scope both the footer's horizontal padding and
   its inner container here so the signature's left edge lands on the same
   viewport-relative offset as .writing-index/.story at every breakpoint. */
body.writing .site-footer {
  padding-inline: var(--space-md);
}

body.writing .site-footer .container {
  width: min(65ch, 100%);
  margin-inline: auto;
}

@media (min-width: 48rem) {
  body.writing .site-footer {
    padding-inline: var(--space-lg);
  }
}
