/* ==========================================================
   NVCSG Pocket Cards — shared styles
   Pure typography. No graphics.
   Brand palette inherits from NVCSG Corporate Style Guide.
   Used by: feelings-needs.html, requests.html, de-escalation.html, self-reset.html, index.html
   ========================================================== */

:root {
  --c-dark:  #1a4d7c;   /* primary dark blue (titles, emphasis) */
  --c-mid:   #2c6ba8;   /* primary medium blue (accents, controls) */
  --c-light: #4a90d9;   /* primary light blue (highlights, h3) */
  --c-bg:    #f0f7fc;   /* light background */
  --c-text:  #2a2a2a;   /* body text */
  --c-mute:  #7a8896;   /* secondary text */
  --c-line:  #d8e4ee;   /* subtle borders */

  --f-display: 'Libre Baskerville', Georgia, serif;
  --f-body:    'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --gap: clamp(12px, 3vw, 24px);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--f-body);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

/* ----- Header (deck pages) ----- */
header.deck-header {
  flex: 0 0 auto;
  padding: calc(var(--gap) + env(safe-area-inset-top)) var(--gap) var(--gap);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
}

.wordmark {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--c-mid);
  letter-spacing: 0.5px;
}

.title {
  font-family: var(--f-body);
  font-weight: 300;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--c-mute);
}

.back-link {
  font-family: var(--f-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--c-mid);
  text-decoration: none;
  letter-spacing: 0.4px;
}

.back-link:hover { color: var(--c-dark); }

/* ----- Section tabs ----- */
nav.tabs {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px var(--gap);
  border-bottom: 1px solid var(--c-line);
}

nav.tabs.hidden { display: none; }

.tab {
  background: none;
  border: none;
  font-family: var(--f-body);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--c-mute);
  padding: 12px 10px 14px;
  cursor: pointer;
  position: relative;
  transition: color 180ms ease;
  flex: 1 1 auto;
  max-width: 130px;
}

.tab:hover { color: var(--c-mid); }
.tab.active { color: var(--c-dark); }

.tab.active::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -1px;
  height: 2px;
  background: var(--c-dark);
  border-radius: 2px;
}

/* ----- Card stage ----- */
main.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  overflow: hidden;
  perspective: 1500px;
  position: relative;
}

/* Card stack — the active card sits on top, the preview card sits behind.
   Both share the same position. When the active card swipes off, the
   preview is revealed in place. */
.card-stack {
  position: relative;
  width: 100%;
  /* Cap width so derived height (width * 7/5) always fits the available
     vertical space — otherwise iOS Safari (URL bar visible) clamps max-height,
     widens the aspect ratio, and `background-size: cover` crops the image's
     top/bottom placeholder rects off the card. */
  max-width: min(460px, calc((100dvh - 240px) * 5 / 7));
  aspect-ratio: 5 / 7;
}

.card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  cursor: pointer;
  will-change: transform;
  /* Simple flip transition — back to the previous behavior. */
  transition: transform 600ms cubic-bezier(0.2, 0.85, 0.3, 1);
}

.card.card-preview {
  /* Sits underneath. Not interactive. Slightly recessed for depth. */
  z-index: 1;
  cursor: default;
  pointer-events: none;
  transform: scale(0.96) translateZ(-1px);
}

.card.card-front {
  z-index: 2;
}

/* Static flipped state — simple rotateY transition handles the animation. */
.card.flipped { transform: rotateY(180deg); }

/* The preview card never flips. */
.card.card-preview.flipped { transform: scale(0.96) translateZ(-1px); }

.face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(26, 77, 124, 0.04),
    0 8px 24px rgba(26, 77, 124, 0.08);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--c-line);
}

/* Front face: NVC.SG branded card-back image with text positioned over
   the built-in white placeholder rectangles. */
.face.front {
  background-image: url('card-front-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #1a4d7c;
  border: none;
}

.face.back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #ffffff 0%, var(--c-bg) 100%);
}

.accent {
  flex: 0 0 auto;
  height: 6px;
  background: var(--c-dark);
}
.face.back .accent { background: var(--c-light); }
/* Hide the accent strip on the front — the image has its own border. */
.face.front .accent { display: none; }
/* Hide the bottom hint on the front — the image already has "Tap card to flip". */
.face.front .hint { display: none; }

/* Card content */
.face .content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px;
  text-align: center;
  min-height: 0;
}

.face.front .content { justify-content: center; }
.face.back .content  { justify-content: flex-start; padding-top: 22px; }

.meta {
  font-family: var(--f-body);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--c-mid);
  padding: 14px 20px 0;
}

.face.back .meta { color: var(--c-light); }

/* Front face: meta text sits in the upper-left white rectangle of the image.
   Multi-word labels (e.g. "Feeling · need met") are split into two lines
   by the JS engine, rendered as `Feeling<br>need met`. */
.face.front .meta {
  position: absolute;
  top: calc(5% - 12px);
  left: 5.5%;
  width: 41%;
  height: 9.5%;
  padding: 0 4%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-dark);
  font-weight: 600;
  font-size: clamp(0.7rem, 2.2vw, 0.92rem);
  letter-spacing: 1.4px;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
}

.head {
  font-family: var(--f-display);
  font-weight: 700;
  color: var(--c-dark);
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}

/* Front-face head sits in the larger middle white rectangle of the image. */
.face.front .content {
  position: absolute;
  top: calc(36% + 20px);
  left: 7%;
  right: 7%;
  height: 22%;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.face.front .head {
  font-family: var(--f-display);
  font-weight: 700;
  color: var(--c-dark);
  line-height: 1.02;
  margin: 0;
  text-align: center;
  text-wrap: balance;
  font-size: clamp(1.7rem, 8.5vw, 3.2rem);
  width: 100%;
  word-break: break-word;
  hyphens: auto;
}

/* Sub text becomes redundant — the image's "Tap card to flip" already hints at the action. */
.face.front .sub { display: none; }

/* Pill-style header on the back face */
.face.back .head {
  display: inline-block;
  font-family: var(--f-body);
  font-weight: 600;
  font-size: clamp(0.95rem, 3.2vw, 1.15rem);
  color: var(--c-dark);
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  padding: 8px 22px;
  margin: 0 auto 22px;
  letter-spacing: 0.3px;
  flex: 0 0 auto;
}

/* Word grid — wraps naturally, not bullet-separated */
.face.back .word-list {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  align-content: flex-start;
  gap: 10px 14px;
  padding: 4px 8px 8px;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.face.back .word-list .word {
  font-family: var(--f-body);
  font-weight: 400;
  color: var(--c-text);
  font-size: clamp(0.92rem, 3.2vw, 1.05rem);
  line-height: 1.3;
  white-space: nowrap;
  padding: 2px 0;
}

.face.back .word-list::-webkit-scrollbar { width: 4px; }
.face.back .word-list::-webkit-scrollbar-thumb {
  background: var(--c-line);
  border-radius: 2px;
}
.face.back .word-list::-webkit-scrollbar-track { background: transparent; }

.face.back .word-list.dense .word {
  font-size: clamp(0.86rem, 2.9vw, 0.98rem);
}
.face.back .word-list.dense {
  gap: 8px 12px;
}

/* Template card style (for Core / framework cards) */
.template {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 400;
  color: var(--c-text);
  font-size: clamp(1rem, 3.6vw, 1.3rem);
  line-height: 1.65;
  margin-top: 18px;
  text-wrap: balance;
  flex-basis: 100%;
  text-align: center;
}

.template .blank {
  display: inline-block;
  min-width: 60px;
  border-bottom: 2px solid var(--c-light);
  padding: 0 4px;
  margin: 0 3px;
}

/* Body card style (for prose-style backs: requests, de-escalation, self-reset) */
.body-card {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 0 4px;
  text-align: left;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.body-card p {
  font-family: var(--f-body);
  font-weight: 400;
  font-size: clamp(0.92rem, 3.2vw, 1.05rem);
  line-height: 1.6;
  color: var(--c-text);
  text-wrap: pretty;
}

.body-card .note {
  font-family: var(--f-body);
  font-style: italic;
  color: var(--c-mute);
  font-size: clamp(0.85rem, 2.9vw, 0.95rem);
  line-height: 1.55;
  border-left: 3px solid var(--c-light);
  padding: 4px 0 4px 12px;
}

.body-card .note strong {
  font-style: normal;
  font-weight: 600;
  color: var(--c-mid);
}

.body-card::-webkit-scrollbar { width: 4px; }
.body-card::-webkit-scrollbar-thumb { background: var(--c-line); border-radius: 2px; }

/* When the back has a template OR body-card, center vertically */
.face.back .word-list:has(.template),
.face.back .word-list:has(.body-card) {
  justify-content: center;
  align-content: flex-start;
  align-items: stretch;
}

/* Hint footer of card */
.hint {
  flex: 0 0 auto;
  padding: 12px 20px 16px;
  text-align: center;
  font-family: var(--f-body);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--c-mute);
  letter-spacing: 0.4px;
}

.face.back .hint { color: var(--c-light); }

/* ----- Footer controls ----- */
footer.controls {
  flex: 0 0 auto;
  padding: var(--gap) var(--gap) calc(var(--gap) + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--c-line);
  background: #fff;
  color: var(--c-dark);
  font-family: var(--f-body);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover { background: var(--c-dark); color: #fff; border-color: var(--c-dark); }
.nav-btn:disabled { opacity: 0.35; cursor: default; }
.nav-btn:disabled:hover { background: #fff; color: var(--c-dark); border-color: var(--c-line); }

.counter {
  font-family: var(--f-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--c-mid);
  letter-spacing: 1.2px;
  min-width: 60px;
  text-align: center;
}

/* ----- Card swipe (front card flying off to reveal preview underneath) -----
   The exiting card lifts forward, tilts back on the X-axis with strong rotation,
   and travels just 75% of its width past its starting edge before disappearing.
   No enter animation — the next card is already visible underneath; the swipe
   simply reveals it. Like flipping through a real deck. */
.card.exiting-fwd  { animation: exitFwd  340ms cubic-bezier(0.45, 0, 0.6, 1) forwards; }
.card.exiting-back { animation: exitBack 340ms cubic-bezier(0.45, 0, 0.6, 1) forwards; }

/* Forward = going to NEXT card. Card swipes LEFT.
   75% of card width past the original right edge = card has shifted -75%.
   rotateY(33deg) spins the right edge AWAY from viewer as it leaves —
   the trailing edge appears to lift and twist as the card flies off. */
@keyframes exitFwd {
  0%   { transform: translateX(0)    translateZ(0)    rotateX(0deg)   rotateY(0deg)  scale(1);    opacity: 1; filter: drop-shadow(0 6px 18px rgba(26, 77, 124, 0.10)); }
  100% { transform: translateX(-75%) translateZ(60px) rotateX(-30deg) rotateY(33deg) scale(0.94); opacity: 0; filter: drop-shadow(0 18px 32px rgba(26, 77, 124, 0.20)); }
}

/* Backward = going to PREV card. Card swipes RIGHT.
   Mirrored rotateY(-33deg) so the LEFT edge twists away. */
@keyframes exitBack {
  0%   { transform: translateX(0)    translateZ(0)    rotateX(0deg)   rotateY(0deg)   scale(1);    opacity: 1; filter: drop-shadow(0 6px 18px rgba(26, 77, 124, 0.10)); }
  100% { transform: translateX( 75%) translateZ(60px) rotateX(-30deg) rotateY(-33deg) scale(0.94); opacity: 0; filter: drop-shadow(0 18px 32px rgba(26, 77, 124, 0.20)); }
}

@media (min-width: 720px) {
  main.stage { padding: 32px; }
  .face .content { padding: 40px 36px; }
}

/* Note: prefers-reduced-motion override is intentionally NOT applied here.
   Card flip + swipe motion is core to the deck's affordance; static cards
   wouldn't communicate "there's a back side" or "there's a next card."
   If a future audience genuinely needs reduced motion, swap these
   keyframes for shorter / lower-amplitude versions rather than disabling. */

/* ==========================================================
   Index page styles (cards landing page)
   ========================================================== */

body.index-page {
  /* Index page is a normal scrolling document — override the deck-page
     flex/100% layout so the 4 deck cards aren't clipped off the viewport. */
  display: block;
  height: auto;
  min-height: 100dvh;
  overflow: auto;
  user-select: text;
  background: var(--c-bg);
}

html:has(body.index-page) {
  height: auto;
  overflow: auto;
}

.index-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(40px + env(safe-area-inset-top)) var(--gap) calc(40px + env(safe-area-inset-bottom));
}

.index-wrap header {
  text-align: center;
  margin-bottom: 36px;
}

.index-wrap h1 {
  font-family: var(--f-display);
  font-weight: 700;
  font-style: italic;
  color: var(--c-dark);
  font-size: clamp(2rem, 6vw, 2.6rem);
  margin-bottom: 8px;
}

.index-wrap h1::after {
  content: "";
  display: block;
  width: 60px;
  height: 3px;
  background: var(--c-mid);
  margin: 12px auto 0;
  border-radius: 2px;
}

.index-wrap .lede {
  font-family: var(--f-body);
  font-weight: 300;
  color: var(--c-mute);
  font-size: 1rem;
  letter-spacing: 0.5px;
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.55;
  text-wrap: balance;
}

.deck-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 32px;
}

@media (min-width: 600px) {
  .deck-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
}

.deck-link {
  display: block;
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: all 180ms ease;
  position: relative;
}

.deck-link:hover {
  border-color: var(--c-mid);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(26, 77, 124, 0.10);
}

.deck-link .deck-meta {
  font-family: var(--f-body);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--c-light);
  margin-bottom: 6px;
}

.deck-link h2 {
  font-family: var(--f-display);
  font-weight: 700;
  color: var(--c-dark);
  font-size: 1.4rem;
  line-height: 1.2;
  margin: 0 0 8px;
}

.deck-link p {
  font-family: var(--f-body);
  font-weight: 400;
  color: var(--c-text);
  font-size: 0.9rem;
  line-height: 1.5;
}

.deck-link .arrow {
  position: absolute;
  top: 22px;
  right: 22px;
  color: var(--c-mid);
  font-size: 1.1rem;
}

.index-footer {
  font-family: var(--f-body);
  font-size: 0.75rem;
  color: var(--c-mute);
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--c-line);
  line-height: 1.6;
}

.index-footer a { color: var(--c-mid); }
