/* ============================================================
   Shared component & utility classes used across pages.
   Design tokens (colors, typography, spacing, effects) live in
   css/theme/ — nothing in this file should hardcode a value
   that exists as a token.
   ============================================================ */

/* === Inline SVG icons === */
/* An .icon sizes to the surrounding text (1em) and takes its color from
   currentColor, so it inherits font-size and color from the text around it.
   The {% icon %} tag and js/icons.js both emit <svg class="icon …">. */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  fill: currentColor;
  /* Nudge onto the text baseline the way an inline font glyph sits. */
  vertical-align: -0.125em;
}

/* === Page Layout Styles === */
/* Large Title */
.title-large {
  font-family: var(--font-heading);
  font-size: var(--font-size-4xl);
  line-height: 1.1;
  font-weight: var(--font-weight-bold);
  margin: 0.4rem 0 1.1rem 0;
  color: var(--color-heading);
  padding-top: var(--space-3xl);
}

/* === Header Link Styles === */
.link-hover-underline {
  position: relative;
  text-decoration: none;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.link-hover-underline::after {
  content: '';
  position: absolute;
  width: 0%;
  height: 2px;
  left: 0;
  bottom: -4px;
  background-color: var(--text-light);
  transition: width var(--transition-fast);
}

.link-hover-underline:hover {
  color: var(--text-light);
}

.link-hover-underline:hover::after {
  width: 100%;
}

/* === Content Link Styles === */

/* Small-caps editorial action link ("Read the Essay", "Listen Now") */
.action-link {
  font-family: var(--font-content);
  font-size: 0.78rem;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--color-accent);
  text-decoration: none;
}

.action-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.content-text-link {
  margin-top: var(--space-xs);
  color: var(--color-accent);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
}

.content-text-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

.section-header {
  font-family: var(--font-heading);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  text-align: left;
  margin: 1rem 0 0.5rem;
  position: relative;
  padding: 0.25rem 0;
  width: 100%;
}

.section-header--large-text {
  font-size: var(--font-size-4xl);
}

.section-header::after {
  content: '';
  display: block;
  height: 1px;
  background-color: var(--color-dark-gray);
  position: absolute;
  left: 0;
  right: 0;
}

.section-header::after {
  bottom: 0;
}

.section-header--muted {
  color: var(--color-heading-muted);
}

.section-header--muted:after {
  color: var(--color-heading-muted);
}

.section-header a {
  text-decoration: none;
  color: var(--color-accent);
  font-size: 0.95rem;
  font-weight: var(--font-weight-medium);
}

.section-header a:hover {
  text-decoration: underline;
  color: var(--color-accent);
}

[id]::before {
  content: '';
  display: block;
  height: 6rem; /* match your header's height or more */
  margin-top: -6rem;
  visibility: hidden;
}

.tag-pill {
  display: inline-block;
  font-size: var(--font-size-small);
  padding: var(--space-xxs) var(--space-xs);
  margin-right: var(--space-xs);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-dark-gray);
  color: var(--color-dark-gray);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  text-decoration: none;
}

.tag-pill:hover,
.tag-pill:focus {
  background-color: var(--color-dark-gray);
  color: var(--color-white);
}

.pill-nav {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.pill {
  padding: 0.25em 1rem;
  border: 1px solid var(--color-dark-gray);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  text-decoration: none;
  color: var(--color-dark-gray);
  transition: all var(--transition-fast);
}

.pill:hover,
.pill:focus,
.pill-selected {
  background-color: var(--color-dark-gray);
  color: var(--color-white);
}

/* === Component Styling === */
.button-reversed {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background-color: transparent;
  border: 2px solid var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  transition: background-color var(--transition-fast),
    color var(--transition-fast);
}

.button-reversed:hover {
  background-color: var(--color-accent);
  color: var(--color-white);
}

.button {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background-color: var(--color-accent);
  border: 2px solid var(--color-accent);
  color: var(--color-white);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  transition: background-color var(--transition-fast),
    color var(--transition-fast);
}

.button:hover {
  background-color: var(--color-white);
  color: var(--color-accent);
}

.button--secondary {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background-color: var(--color-black);
  border: 2px solid var(--color-black);
  color: var(--color-white);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  transition: background-color var(--transition-fast),
    color var(--transition-fast);
}

.button--secondary:hover {
  background-color: var(--color-white);
  color: var(--color-black);
}

.button--secondary-reversed {
  background-color: var(--color-background);
  border-color: var(--color-border);
  color: var(--color-gray-text);
}

.button--small {
  padding: 0.3rem 0.8rem;
  font-size: 0.9rem;
}

.button.disabled,
.button--secondary.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
  text-decoration: none; /* ensure they don't look like links */
}

.link-button {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
}

.link-button:hover {
  text-decoration: underline;
}

.heading-link {
  text-decoration: none;
  color: var(--color-heading);
  font-weight: inherit;
}

.heading-link--muted {
  color: var(--color-heading-muted);
}

.heading-link:hover {
  text-decoration: underline;
  color: var(--color-accent);
}

.essay-subtitle {
  font-size: var(--font-size-base);
  font-style: italic;
  font-weight: var(--font-weight-regular);
  color: var(--color-text);
  border-left: 4px solid var(--color-accent);
  padding-left: var(--space-md);
  margin-bottom: 1.25rem;
  opacity: 0.95;
}

.essay-subtitle--fixed-height {
  height: 4.8rem; /* Adjust to fit 2-3 lines based on your font/line-height */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3; /* number of lines to show */
  line-clamp: 3;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
}

.newsletter_signup {
  display: flex;
  justify-content: center;
}

/* iframe itself */
.newsletter-iframe {
  width: 100%;
  max-width: 720px; /* keeps it from getting too wide on big screens */
  min-height: 420px; /* enough room for the form */
  border: none !important; /* kills the purple border */
  outline: none !important;
  box-shadow: none !important;
  display: block;
}

.section-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--color-heading-text);
  font-family: var(--font-heading);
  font-size: var(--font-size-base);
  letter-spacing: 0.05em;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-2xl);
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--color-heading-text);
}

.section-divider-thin {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--color-heading-text);
  font-family: var(--font-heading);
  font-size: var(--font-size-base);
  letter-spacing: 0.05em;
  margin-top: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.section-divider-thin::before,
.section-divider-thin::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--color-heading-text);
}

/* Bookmark form + button */
.bookmark-form {
  margin: 0;
}

/* Same treatment on essay, artist, and playlist detail pages */
.bookmark-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-black);
  background-color: var(--color-bg);
  font-size: var(--font-size-medium);
  cursor: pointer;
  color: var(--color-body-text);
  transition: background-color var(--transition-fast),
    border-color var(--transition-fast), color var(--transition-fast);
}

.bookmark-btn i {
  font-size: 0.9rem;
}

.bookmark-btn:hover,
.bookmark-btn--active:hover {
  background-color: var(--color-background-light);
  color: var(--color-heading);
  border-color: var(--color-dark-gray);
}

/* Active (Bookmarked) state */
.bookmark-btn--active {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-white);
}

.bookmark-btn--active i {
  color: var(--color-white);
}

.bookmark-btn--active:hover i {
  color: var(--color-black);
}

/* In a quiet action row the bookmark carries its state with color and glyph
   rather than a filled pill: muted when unsaved, accent when saved, matching
   the way Share signals its own copied state. Scoped to .detail-actions so the
   standalone .bookmark-btn elsewhere keeps its outlined treatment. */
.detail-actions .bookmark-btn {
  color: var(--color-subtle-text);
}

.detail-actions .bookmark-btn:hover,
.detail-actions .bookmark-btn--active:hover {
  background: none;
  border: 0;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.detail-actions .bookmark-btn--active,
.detail-actions .bookmark-btn--active i,
.detail-actions .bookmark-btn--active:hover i {
  color: var(--color-accent);
}

/* Logged-out hint link. Shares its geometry and weight with .share-btn (see
   the .detail-actions quiet-action rule below): signed out, the row is a pair
   of quiet text actions rather than a text link beside a boxed button. */
.bookmark-login-hint {
  color: var(--color-subtle-text);
  text-decoration: none;
}

.bookmark-login-hint:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Detail-page action row: bookmark + share sit side by side. */
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
}

/* One geometry for every quiet action in the row, so the pair reads as a set
   whatever the auth state — and so Share still looks deliberate standing alone
   on the writer page, which has no bookmark control. The 44px min-height is the
   iOS/Android tap-target floor; the negative inline margin keeps the enlarged
   target from visually indenting the text past the page gutter.

   The signed-in .bookmark-btn is included: left on its default outlined-pill
   treatment it sat as a boxed button beside a quiet text Share, so the row read
   as two unrelated kinds of control. Bookmarked-vs-not is still legible from the
   filled glyph and the accent color below — it does not need a box to carry it. */
.detail-actions .bookmark-login-hint,
.detail-actions .bookmark-btn,
.detail-actions .share-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  min-height: 44px;
  margin-inline: calc(var(--space-xs) * -1);
  padding: var(--space-xxs) var(--space-xs);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-family: var(--font-ui);
  font-size: var(--font-size-medium);
  line-height: 1.2;
}

/* Share button — same outline treatment as .bookmark-btn so the pair reads as
   one control group. Clicking copies the page URL; see js/share.js.
   Positioned so the "Link copied" toast can anchor to it. */
.share-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Geometry comes from the .detail-actions rule above, which Share shares with
   the signed-out bookmark link. Only the interactive bits live here. */
.share-btn {
  cursor: pointer;
  color: var(--color-subtle-text);
  transition: color var(--transition-fast);
}

.share-btn:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* The copied-confirmation state swaps the button's own icon + label in place
   (link glyph -> check) and tints it with the success token for ~2s. The check
   is hidden until then; the link icon is hidden while copied. */
.share-btn-icon {
  display: inline-flex;
  align-items: center;
}

.share-btn-icon--copied {
  display: none;
}

.share-btn.is-copied {
  color: var(--color-success);
}

.share-btn.is-copied .share-btn-icon--share {
  display: none;
}

.share-btn.is-copied .share-btn-icon--copied {
  display: inline-flex;
}

/* "Link copied" toast — a small popup above the button, revealed for the same
   ~2s as the is-copied state. Pointer-events off so it never swallows a second
   click; `visibility` (not display) so the fade can actually run.

   Anchored to the button's LEFT edge, not centred on it: this row wraps on
   narrow screens and the button can end up near the right gutter, where a
   centred nowrap popup would overflow the viewport. */
.share-toast {
  position: absolute;
  bottom: calc(100% + var(--space-xxs));
  left: 0;
  z-index: 2;
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--radius-sm);
  background-color: var(--color-black);
  color: var(--text-light);
  font-family: var(--font-ui);
  font-size: var(--font-size-small);
  white-space: nowrap;
  box-shadow: var(--shadow-lifted);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(var(--space-xxs));
  transition: opacity var(--transition-fast), transform var(--transition-fast),
    visibility var(--transition-fast);
}

/* The little pointer connecting the toast to the button, sat over the icon. */
.share-toast::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--space-md);
  border: 4px solid transparent;
  border-top-color: var(--color-black);
}

.share-wrapper.is-copied .share-toast {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .share-toast {
    transition: none;
    transform: translateY(0);
  }
}

/* Visually-hidden live region: the toast and the label/icon swap are the seen
   cues, this just announces "Link copied" to screen readers. */
.share-btn-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Component titles (was component_styles.css) === */
.component-title {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  text-align: center;
}

.component-title__heading {
  font-size: 1.75rem;
  font-weight: var(--font-weight-bold);
  border-bottom: 2px solid var(--color-light-gray);
  padding-bottom: var(--space-xxs);
  color: var(--color-dark-gray);
}

/* ============================================================
   Responsive — phone (--bp-phone, see theme/breakpoints.css)
   Shared component overrides moved here out of base_styles/mobile.css,
   so each component's responsive tail lives with the component.
   ============================================================ */
@media (max-width: 54rem) {
  .pill-nav {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
  }

  .pill {
    width: 100%;
    max-width: 6rem;
    text-align: center;
    font-size: var(--font-size-small);
    padding: 0.15rem 0.25rem;
  }

  .section-header {
    font-size: var(--font-size-section-heading-mobile);
    padding: 0.5rem 0;
    margin: 2rem 0 1rem 0;
    text-align: left;
  }

  .newsletter-iframe {
    height: 500px; /* mobile forms stretch a LOT */
  }
}

/* ============================================================
   SECTION LABEL BAR
   Heavy top rule + small-caps accent label, used to open a section. The label
   carries the accent so the brand colour appears down the whole page rather
   than only on buttons, and the bar doubles as the section's "see all" row:
   heading left, link right, one element doing two jobs.

   Lives here rather than in a page stylesheet because it is shared: the
   homepage sections and the artist page's influence ledger both use it, and
   page_styles/*.css is only loaded on its own page.
   ============================================================ */
.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
  border-top: 2px solid var(--color-black);
  padding-top: 0.6rem;
  margin: 3.5rem 0 1.5rem;
}

.section-bar span {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps-wide);
  color: var(--color-accent);
}

.section-bar-link {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--color-subtle-text);
  text-decoration: none;
  white-space: nowrap;
}

.section-bar-link:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* On a dark band the same bar inverts: the rule and label take the lighter
   accent tint, since the full-strength accent on near-black is unreadable. */
.section-bar--on-dark {
  border-top-color: var(--color-accent);
}

.section-bar--on-dark span {
  color: var(--color-accent-on-dark);
}

.section-bar--on-dark .section-bar-link {
  color: var(--text-muted);
}

.section-bar--on-dark .section-bar-link:hover {
  color: var(--color-accent-on-dark);
}

@media (max-width: 54rem) { /* --bp-phone */
  .section-bar {
    margin: 2.5rem 0 1.25rem;
  }

  /* Comfortable thumb target: these are small text links sized for a mouse.
     The negative margin keeps the enlarged hit area from pushing the bar's
     baseline alignment around. */
  .section-bar-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    margin: -0.75rem 0;
  }
}

/* ---------- Newsletter call-to-action (partials/newsletter_cta.html) ----------
   The compact signup on artist and writer pages. A ruled block in the reading
   column, not a banner or a popup: it should read as part of the page. The
   form inside is the shared .nl-form (global_styles.css), which already wraps
   the button under the input on a phone. Tokens only. */
.newsletter-cta {
  max-width: 40rem;
  margin: var(--space-xl) 0;
  padding: var(--space-lg) 0;
  border-top: 2px solid var(--color-accent);
  border-bottom: 1px solid var(--color-divider);
}

.newsletter-cta-kicker {
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--color-accent);
  margin: 0 0 var(--space-xs);
}

.newsletter-cta-heading {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  line-height: var(--line-height-tight);
  color: var(--color-heading-text);
  margin: 0 0 var(--space-xs);
  text-wrap: balance;
}

.newsletter-cta-body {
  font-family: var(--font-content);
  font-size: var(--font-size-md);
  line-height: var(--line-height-relaxed);
  color: var(--color-subtle-text);
  margin: 0;
}

.newsletter-cta-trust {
  font-size: var(--font-size-xs);
  color: var(--color-subtle-text);
  margin: var(--space-sm) 0 0;
}

/* After a signup the view redirects to "#newsletter-form" so the status
   message is in view. The header is fixed (one 4rem row), so without an offset
   the browser parks the form's top edge underneath it. Header height plus a
   little air. Applies to every page's signup anchor. */
#newsletter-form {
  scroll-margin-top: calc(var(--space-3xl) + var(--space-md));
}
