/* Reset + base */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #050610;
  color: #e4e4e7;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: block;
  width: 100vw;
  height: 100dvh;
}

/* Feed container — owns the two-card deck. Only the current and next
   card live in the DOM; advancement is a CSS transform transition, not
   native scrolling (tech-spec §4.5). */
#feed {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  touch-action: none; /* gestures are handled in swipe.js */
}

.deck {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.deck__slot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100dvh;
  transition: transform 250ms cubic-bezier(0.32, 0.72, 0.24, 1);
  will-change: transform;
}

/* Three slots — prev (above), current (visible), next (below). All three
   are mounted simultaneously so a drag gesture has cards already laid out
   above and below the viewport. The commit transition is driven by inline
   transforms set in app.js (single property mutation per element); these
   class transforms are the resting state before/after the gesture and the
   target the inline values match at cleanup time. */
.deck__slot--prev     { transform: translateY(-100%); z-index: 1; }
.deck__slot--current  { transform: translateY(0);     z-index: 2; }
.deck__slot--next     { transform: translateY(100%);  z-index: 1; }

/* While the user's finger is on the screen, transitions are suppressed —
   the deck tracks the pointer 1:1 via inline transforms set in app.js. */
.deck--dragging .deck__slot { transition: none; }

/* Card frame */
.card {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.card__inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 33.75rem; /* 540px — matches mockup */
  padding: clamp(1.75rem, 6vw, 2.5rem) clamp(1.25rem, 5vw, 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
}

.card__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.card__text {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}

/* Type-specific typography */

.type-verse           .card__text { font-size: 2.2rem; }
.type-classical_quote .card__text { font-size: 1.7rem; font-style: italic; }
.type-prayer          .card__text { font-size: 1.5rem; line-height: 1.5; }
.type-hymn            .card__text { font-size: 1.5rem; line-height: 1.5; }
.type-breath          .card__text { font-size: 4rem; font-weight: 300; letter-spacing: 0.02em; }

/* Length overrides */

.length-micro  .card__text { font-size: 4rem;   line-height: 1.1; }
.length-medium .card__text { font-size: 1.4rem; }

.type-breath.length-micro .card__text { font-size: 4.5rem; }

/* Register typography overrides */

.register-bracing .card__text { font-weight: 500; letter-spacing: -0.02em; }
.register-still   .card__text { font-weight: 300; }
.register-glad    .card__text { font-weight: 500; }

/* Metadata row */

.card__meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1rem;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.card__reference, .card__translation, .card__attribution, .card__badge, .card__credit {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-muted);
}

.card__reference--faint { opacity: 0.65; }

.card__badge {
  border: 1px solid var(--text-muted);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

/* Treatment-specific tweaks */

.treatment-symbolic .card__mark {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 4rem;
  height: 4rem;
  color: var(--accent);
  opacity: 0.85;
}

.treatment-symbolic .card__mark--background_faint {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  opacity: 0.08;
  pointer-events: none;
}

.treatment-image_led .card__image {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
}

.treatment-image_led .card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.treatment-image_led .card__inner .card__text {
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.85);
}

.treatment-image_led .card__credit {
  position: absolute;
  bottom: 0.5rem;
  right: 0.75rem;
  font-size: 0.6rem;
  opacity: 0.55;
  z-index: 3;
}

/* ============================================================
   v3 MEDIA KINDS — photo, art, video
   The .card frame normally paints a palette gradient; media kinds
   replace that with a full-bleed image/video and a gradient overlay
   for caption legibility. CSS contract per mixed-media-mockup.html.
   ============================================================ */

.kind-photo, .kind-video {
  background: #050610;
  background-image: none;
}

.kind-photo > .card__media,
.kind-video > .card__media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.45) 60%,
    rgba(0, 0, 0, 0.85) 100%
  );
  z-index: 1;
  pointer-events: none;
}

.card__content--over-media {
  position: absolute;
  bottom: 8vh;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 0 clamp(1.25rem, 5vw, 2rem);
  text-align: center;
  color: #fff;
}

.card__content--over-media .card__caption {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 400;
  font-size: clamp(1.4rem, 4.4vw, 1.6rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 0 auto;
  max-width: 33.75rem;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.85);
  color: #fff;
}

.card__content--over-media .card__meta {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  margin-top: 0.6rem;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
}

.card__content--over-media .card__reference {
  color: inherit;
}

.card__content--over-media .card__credit {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.55);
  margin: 0.4rem auto 0;
  max-width: 28.75rem;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
}

/* ART — the work is the focus, framed not cropped */

.kind-art {
  background: radial-gradient(ellipse at center, #1a1410 0%, #050201 90%);
  background-image: radial-gradient(ellipse at center, #1a1410 0%, #050201 90%);
}

.kind-art .card__art-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  padding: 6vh 0 28vh 0;
}

.kind-art .card__art-img {
  max-width: 92vw;
  max-height: 100%;
  object-fit: contain;
  filter: brightness(0.85) contrast(1.05);
  box-shadow: 0 8px 60px rgba(0, 0, 0, 0.6);
}

.kind-art .card__art-img--full-bleed {
  width: 100vw;
  max-width: 100vw;
  height: 100%;
  max-height: 100%;
  object-fit: cover;
  box-shadow: none;
}

.kind-art .card__content--art {
  position: absolute;
  bottom: 5vh;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 0 clamp(1.25rem, 5vw, 2rem);
  text-align: center;
  color: #f0e8d8;
}

.kind-art .card__content--art .card__caption {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.25rem, 3.8vw, 1.4rem);
  line-height: 1.35;
  margin: 0 auto;
  max-width: 33.75rem;
  color: #f0e8d8;
}

.kind-art .card__content--art .card__meta {
  color: rgba(240, 232, 216, 0.7);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  margin-top: 0.4rem;
}

.kind-art .card__content--art .card__reference {
  color: inherit;
}

.kind-art .card__content--art .card__credit {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  color: rgba(240, 232, 216, 0.5);
  margin: 0.3rem auto 0;
  max-width: 28.75rem;
}

/* Floating UI buttons (wired in later sessions) */

#topic-button, #settings-button {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.4);
  color: rgba(228, 228, 231, 0.7);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

#topic-button:hover, #settings-button:hover,
#topic-button:focus-visible, #settings-button:focus-visible {
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.55);
  outline: none;
}

#topic-button { left: 1rem; }
#settings-button { right: 1rem; }

/* Active-topic chip */

.active-topic-chip {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top, 0.75rem));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.9);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
}

.active-topic-chip[hidden] { display: none; }

.active-topic-chip__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
  transition: opacity 120ms ease, background-color 120ms ease;
}

.active-topic-chip__close:hover,
.active-topic-chip__close:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

/* Bottom sheet */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  margin: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0);
  transition: background-color 200ms ease;
  cursor: pointer;
  pointer-events: auto;
}

.sheet--open .sheet__backdrop { background: rgba(0, 0, 0, 0.5); }
.sheet--closing .sheet__backdrop { background: rgba(0, 0, 0, 0); }

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 33.75rem;
  margin: 0 auto;
  padding: 0.5rem clamp(1rem, 4vw, 1.5rem) max(1rem, env(safe-area-inset-bottom, 1rem));
  background: #121319;
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #e4e4e7;
  max-height: 85dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 200ms cubic-bezier(0.32, 0.72, 0.24, 1);
  pointer-events: auto;
}

.sheet--open .sheet__panel { transform: translateY(0); }
.sheet--closing .sheet__panel { transform: translateY(100%); }

.sheet__handle {
  width: 2.5rem;
  height: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0.5rem auto 0.75rem;
}

.sheet__title {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  margin: 0 0 1rem;
  text-align: center;
}

.sheet__content { padding-bottom: 1rem; }

/* Topic picker */

.topic-picker__tier {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin: 1.25rem 0 0.5rem;
}

.topic-picker__list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.topic-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.topic-row:hover:not(:disabled),
.topic-row:focus-visible {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  outline: none;
}

.topic-row--selected {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}

.topic-row--all {
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.5rem 0.5rem 0 0;
  padding-bottom: 0.85rem;
}

.topic-row--disabled {
  opacity: 0.4;
  cursor: default;
}

.topic-row__sub {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

/* Settings sheet */

.settings-section { margin: 0 0 1.5rem; }

.settings-section__title {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin: 0 0 0.5rem;
}

.settings-section__body {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.45;
  color: rgba(228, 228, 231, 0.85);
  margin: 0;
}

.settings-pack-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-pack {
  padding: 0.85rem 0.9rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-pack__title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 0.25rem;
}

.settings-pack__description {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: rgba(228, 228, 231, 0.8);
  font-family: "Cormorant Garamond", Georgia, serif;
}

.settings-pack__action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.settings-pack__price {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.6);
}

.settings-pack__buy {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.settings-pack__buy:hover:not(:disabled),
.settings-pack__buy:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
  outline: none;
}

.settings-pack__buy:disabled {
  opacity: 0.6;
  cursor: default;
}

.settings-pack__buy--owned {
  border-color: rgba(150, 220, 170, 0.32);
  color: rgba(190, 230, 200, 0.85);
  opacity: 0.9;
}

.settings-pack__note {
  margin: 0.5rem 0 0;
  padding: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  line-height: 1.35;
  letter-spacing: 0.04em;
  color: rgba(245, 180, 180, 0.85);
}

/* iOS install hint (re-uses sheet primitive) */

.ios-install-hint__body,
.ios-install-hint__note {
  font-family: "Cormorant Garamond", Georgia, serif;
  line-height: 1.5;
  margin: 0 0 0.75rem;
}

.ios-install-hint__body { font-size: 1.1rem; }
.ios-install-hint__note { font-size: 0.95rem; color: rgba(228, 228, 231, 0.7); }

/* Install banner */

.install-banner {
  position: fixed;
  left: 50%;
  bottom: max(4rem, calc(env(safe-area-inset-bottom, 0px) + 4rem));
  transform: translate(-50%, 1rem);
  width: min(28rem, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(18, 19, 25, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  color: #e4e4e7;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
  z-index: 15;
}

.install-banner--in {
  transform: translate(-50%, 0);
  opacity: 1;
}

.install-banner--out {
  transform: translate(-50%, 1rem);
  opacity: 0;
}

.install-banner__text {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1rem;
  line-height: 1.4;
}

.install-banner__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.install-banner__dismiss,
.install-banner__install {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.install-banner__install {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

.install-banner__dismiss:hover,
.install-banner__install:hover,
.install-banner__dismiss:focus-visible,
.install-banner__install:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

/* Empty state */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  color: #6a6a64;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
