/* =========================================================================
   Witch — Card Meanings pages.
   Loaded after style.css (tokens, fonts, backdrop, nav, suit accents).
   This file: overview/suit/card page layout, the card grid + hover flip,
   the upright/reversed toggle, keyword chips, and metadata sections.
   ========================================================================= */

.cm-main {
  position: relative;
  z-index: 3;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(96px, 14vh, 132px) clamp(18px, 5vw, 48px) 40px;
}

/* visually hidden but focusable (the orientation radios) */
.cm-vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* ------------------------------ shared bits ---------------------------- */
.cm-title {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.05;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}

.cm-lede {
  margin: 16px auto 0;
  max-width: 56ch;
  color: var(--ink-70);
  font-size: clamp(15.5px, 2vw, 18px);
  line-height: 1.6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.cm-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.cm-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-50);
  margin-bottom: 26px;
}
.cm-breadcrumb a { color: var(--ink-70); text-decoration: none; transition: color 0.2s var(--ease); }
.cm-breadcrumb a:hover { color: var(--ink); }
.cm-breadcrumb .cm-bc-sep { color: var(--ink-35); }
.cm-breadcrumb [aria-current="page"] { color: var(--ink); }

.cm-cta-pill,
.cm-overview-cta .cm-cta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 12px 28px;
  border-radius: 999px;
  background: var(--frost);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  color: var(--ink);
  font-weight: 800;
  font-size: 14.5px;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.25s var(--ease), background 0.2s var(--ease);
}
.cm-cta-pill:hover {
  background: var(--frost-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(232, 201, 138, 0.18);
}

/* ------------------------------- overview ------------------------------ */
.cm-hero-overview { text-align: center; padding: 12px 0 8px; }
.cm-hero-overview .cm-title { font-size: clamp(40px, 6.5vw, 76px); }

.cm-overview-cta {
  margin: clamp(40px, 7vh, 80px) auto 20px;
  text-align: center;
  max-width: 540px;
}
.cm-overview-cta-text {
  color: var(--ink-70);
  font-size: 17px;
  line-height: 1.55;
  margin-bottom: 22px;
}

/* --------------------------------- suit -------------------------------- */
.cm-hero-suit { text-align: center; padding: 4px 0 10px; }
.cm-hero-suit .cm-title { font-size: clamp(38px, 6vw, 68px); }

.cm-suit-emblem {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 112px; height: 112px;
  margin-bottom: 6px;
}
.cm-suit-emblem-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, var(--suit-accent, var(--gold)) 0%, transparent 70%);
  opacity: 0.28;
  filter: blur(6px);
}
.cm-suit-icon { position: relative; width: 72px; height: 72px; filter: brightness(0) invert(1) drop-shadow(0 4px 12px rgba(0,0,0,0.4)); }

.cm-suit-meta {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--suit-accent, var(--gold));
}

/* ------------------------------- card grid ----------------------------- */
.cm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: clamp(16px, 2.4vw, 28px);
  margin-top: clamp(36px, 6vh, 64px);
}

.cm-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  perspective: 1000px;
  border-radius: 12px;
}
.cm-tile-inner {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: var(--card-ratio);
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease);
}
.cm-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.cm-face-front img {
  width: 100%; height: 100%;
  object-fit: fill; /* stretch the taller scans into 2:3, no cropping (matches the homepage fan) */
}
.cm-tile-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 22px 10px 9px;
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(to top, rgba(6, 9, 13, 0.92) 12%, transparent);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.cm-face-back {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* upright pinned top, reversed pinned bottom */
  gap: 12px;
  padding: 18px 14px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--suit-accent, #2a3242) 28%, var(--surface-strong)), var(--surface-strong));
  border: 1px solid color-mix(in srgb, var(--suit-accent, #fff) 30%, transparent);
}
.cm-tile-kw {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-70);
}
.cm-tile-kw b {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--suit-accent, var(--gold));
  margin-bottom: 3px;
}

/* desktop: flip on hover/focus. touch: no flip (front always shows). */
@media (hover: hover) and (pointer: fine) {
  .cm-tile:hover .cm-tile-inner,
  .cm-tile:focus-visible .cm-tile-inner { transform: rotateY(180deg); }
  .cm-tile:hover .cm-face-front,
  .cm-tile:focus-visible .cm-face-front { box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6); }
}
@media (hover: none) {
  .cm-face-back { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cm-tile-inner { transition: none; }
}

/* ------------------------------- card page ----------------------------- */
.cm-card { max-width: 900px; margin: 0 auto; }

.cm-card-hero {
  display: flex;
  gap: clamp(24px, 4vw, 52px);
  align-items: center;
  margin-bottom: clamp(40px, 6vh, 72px);
}

.cm-card-figure {
  position: relative;
  flex: 0 0 auto;
  width: clamp(180px, 30vw, 256px);
  aspect-ratio: var(--card-ratio);
}
.cm-card-figure-glow {
  position: absolute;
  inset: -16%;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, var(--suit-accent, var(--gold)) 0%, transparent 68%);
  opacity: 0.22;
  filter: blur(14px);
  pointer-events: none;
}
.cm-card-img {
  position: relative;
  width: 100%; height: 100%;
  object-fit: fill; /* stretch into 2:3, no cropping (matches the homepage fan) */
  border-radius: 12px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: transform 0.6s var(--ease);
}

.cm-card-head { flex: 1; min-width: 0; }

.cm-card-suit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--suit-accent, var(--gold));
  margin-bottom: 10px;
}
.cm-card-suit-icon { width: 20px; height: 20px; filter: brightness(0) invert(1); }

.cm-card-name {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

/* segmented upright/reversed control */
.cm-orient {
  display: inline-flex;
  margin-top: 20px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.cm-orient-seg {
  cursor: pointer;
  padding: 9px 22px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-50);
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
  -webkit-user-select: none;
  user-select: none;
}
/* default = upright active */
#cm-up:checked ~ .cm-card-hero .cm-orient-seg-up,
#cm-rev:checked ~ .cm-card-hero .cm-orient-seg-rev {
  color: #131922;
  background: var(--suit-accent, var(--gold));
}
.cm-orient-input:focus-visible ~ .cm-card-hero .cm-orient {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* reversed flips the card image */
#cm-rev:checked ~ .cm-card-hero .cm-card-img { transform: rotate(180deg); }

/* orientation-dependent content: explicit per element so display modes
   (flex chips vs block quote) survive the swap. Default = upright shown. */
.cm-chips.cm-rev { display: none; }
.cm-advice-quote.cm-rev { display: none; }
#cm-rev:checked ~ .cm-card-hero .cm-chips.cm-up { display: none; }
#cm-rev:checked ~ .cm-card-hero .cm-chips.cm-rev { display: flex; }
#cm-rev:checked ~ .cm-card-body .cm-advice-quote.cm-up { display: none; }
#cm-rev:checked ~ .cm-card-body .cm-advice-quote.cm-rev { display: block; }

.cm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  list-style: none;
}
.cm-chip {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
  background: var(--frost);
  border: 1px solid color-mix(in srgb, var(--suit-accent, #fff) 26%, rgba(255, 255, 255, 0.12));
}

/* card body blocks */
.cm-card-body {
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 4vh, 44px);
  max-width: 660px;
}
.cm-block-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-50);
  margin-bottom: 12px;
}
.cm-block p {
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink-70);
}

.cm-advice-quote {
  font-family: var(--display);
  font-size: clamp(19px, 2.6vw, 24px);
  line-height: 1.45;
  color: var(--ink);
  padding-left: 20px;
  border-left: 3px solid var(--suit-accent, var(--gold));
}

/* metadata sections */
.cm-meta-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.cm-meta-icon {
  width: 34px; height: 34px;
  flex: none;
  /* element/zodiac/crystal SVGs ship dark, planets ship white; normalize to white */
  filter: brightness(0) invert(1) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}
.cm-meta-title {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cm-meta-value {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.cm-num-badges { display: inline-flex; gap: 6px; flex: none; }
.cm-num-badge {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--frost);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-family: var(--display);
  font-size: 17px;
}

/* prev / next */
.cm-prevnext {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin-top: clamp(44px, 7vh, 80px);
  padding-top: 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.cm-pn {
  text-decoration: none;
  color: var(--ink-70);
  font-size: 14px;
  transition: color 0.2s var(--ease), transform 0.2s var(--ease);
}
.cm-pn-prev { justify-self: start; text-align: left; }
.cm-pn-next { justify-self: end; text-align: right; }
.cm-pn-dir {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-35);
  margin-bottom: 3px;
}
.cm-pn-name { font-weight: 700; color: var(--ink); }
.cm-pn-prev:hover, .cm-pn-next:hover { color: var(--ink); }
.cm-pn-prev:hover { transform: translateX(-3px); }
.cm-pn-next:hover { transform: translateX(3px); }
.cm-pn-all {
  justify-self: center;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.cm-pn-all:hover { background: var(--surface-strong); color: var(--ink); }
.cm-pn-empty { pointer-events: none; }

/* ------------------------------ responsive ----------------------------- */
@media (max-width: 680px) {
  .cm-card-hero { flex-direction: column; text-align: center; }
  .cm-card-suit { justify-content: center; }
  .cm-orient { margin-left: auto; margin-right: auto; }
  .cm-chips { justify-content: center; }
  .cm-card-body { margin-left: auto; margin-right: auto; }
  .cm-advice-quote { text-align: left; }
  .cm-pn-name { font-size: 13px; }
}
