/* Orbital Interactive Card Showcase (#practice)
   Notion-inspired centered elevated card framed by smoothly orbiting tactile subject medallions,
   subtle bottom-right play/pause control, and a whisper-quiet docked card-type switcher. */

/* ----------------------------------------------------- Centered Editorial Head */
#practice {
  padding-top: clamp(1rem, 1.8vw, 1.45rem);
  padding-bottom: clamp(2.8rem, 5vw, 4.4rem);
}

#practice .sec-head-left {
  justify-content: center;
  text-align: center;
  margin-bottom: clamp(0.45rem, 1vw, 0.72rem);
}

#practice .sec-head-left > div {
  margin-inline: auto;
  max-width: 44rem;
}

#practice .sec-h2 {
  font-size: clamp(1.85rem, 3vw, 2.55rem);
  line-height: 1.04;
  letter-spacing: -0.038em;
}

#practice .sec-lead {
  margin: 0.4rem auto 0;
  max-width: 39rem;
  font-size: clamp(0.9rem, 1.06vw, 0.96rem);
  line-height: 1.45;
}

/* ----------------------------------------------------- Playground Base Shell */
#practice .ex-playground {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.15rem;
  align-items: start;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
}

.orb-arena {
  position: relative;
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1450px;
}

/* Elevated Central Card Frame (Light & Dark Modes) + 3D Card Flip */
#practice .ex-stage {
  position: relative;
  z-index: 4;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1rem 1.05rem 0.85rem;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  box-shadow:
    0 24px 56px -22px rgba(13, 18, 24, 0.13),
    0 8px 20px -8px rgba(13, 18, 24, 0.06),
    0 1px 2px rgba(13, 18, 24, 0.04);
  transition:
    background-color 0.22s var(--ease),
    border-color 0.22s var(--ease),
    box-shadow 0.26s var(--ease);
}

#practice .ex-stage.is-flip-out {
  transform: rotateY(84deg) scale(0.96);
  opacity: 0.35;
  transition:
    transform 0.16s cubic-bezier(0.42, 0, 1, 1),
    opacity 0.15s ease-in;
}

#practice .ex-stage.is-flip-in-start {
  transform: rotateY(-84deg) scale(0.96);
  opacity: 0.35;
  transition: none !important;
}

#practice .ex-stage.is-flip-in {
  transform: rotateY(0deg) scale(1);
  opacity: 1;
  transition:
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.24s ease-out;
}

[data-theme="dark"] #practice .ex-stage {
  background: var(--card);
  border-color: rgba(255, 255, 255, 0.105);
  box-shadow:
    0 32px 76px -18px rgba(0, 0, 0, 0.74),
    0 10px 26px -6px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.065);
}

#practice .ex-body {
  position: relative;
  padding: 0;
  min-height: 17.5rem;
}

#practice .ex-foot {
  margin-top: 0.25rem;
  padding: 0.45rem 0 0;
  border-top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem 0.85rem;
}

#practice .ex-foot .btn {
  border-radius: var(--radius-pill);
  padding: 0 1.1rem;
}

#practice .ex-foot .btn-ghost {
  border-color: transparent;
  background: transparent;
  padding: 0 0.65rem;
  color: var(--muted-foreground);
}

#practice .ex-foot .btn-ghost:hover {
  border-color: transparent;
  background: var(--surface);
  color: var(--foreground);
}

/* Orbital Chrome — hidden cleanly on mobile & tablet (< 960px) */
.orb-track,
.orb-ring,
.orb-tooltip,
.orb-toggle {
  display: none;
}

/* ----------------------------------------------------- Desktop Orbital Stage (>= 960px) */
@media (min-width: 960px) {
  #practice .ex-playground {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    grid-template-columns: none;
  }

  .orb-arena {
    padding: 0.35rem 0;
    height: clamp(27.5rem, 56vh, 31.5rem);
    min-height: 27.5rem;
  }

  #practice .ex-stage {
    width: 100%;
    max-width: clamp(32rem, 48vw, 37.25rem);
    height: 100%;
    max-height: 30.5rem;
    margin: 0 auto;
    padding: 1rem 1.25rem 0.82rem;
    border-radius: 22px;
  }

  #practice .ex-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    padding-right: 0;
  }

  #practice .ex-body iframe {
    width: 100%;
    margin: auto 0;
    flex-shrink: 0;
    transform-origin: top center;
  }

  /* Whisper-faint orbital hairline path */
  .orb-track {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
  }

  .orb-track path {
    fill: none;
    stroke: var(--border);
    stroke-width: 1;
    opacity: 0.52;
  }

  [data-theme="dark"] .orb-track path {
    stroke: rgba(255, 255, 255, 0.08);
    opacity: 0.72;
  }

  /* Orbiting Medallions Layer (strictly behind central card z-index 4) */
  .orb-ring {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
  }

  .orb-medallion {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    padding: 0;
    border: 1px solid rgba(13, 13, 13, 0.085);
    border-radius: 50%;
    background: #ffffff;
    color: var(--foreground);
    display: grid;
    place-items: center;
    cursor: pointer;
    pointer-events: auto;
    box-shadow:
      0 12px 28px -8px rgba(13, 18, 24, 0.14),
      0 3px 8px -2px rgba(13, 18, 24, 0.07),
      inset 0 1px 0 rgba(255, 255, 255, 0.92);
    transition:
      border-color 0.2s var(--ease),
      background-color 0.2s var(--ease),
      box-shadow 0.22s var(--ease);
  }

  .orb-medallion[data-shape="squircle"] {
    border-radius: 17px;
  }

  [data-theme="dark"] .orb-medallion {
    background: #171b22;
    border-color: rgba(255, 255, 255, 0.115);
    box-shadow:
      0 14px 34px -8px rgba(0, 0, 0, 0.7),
      0 3px 10px -2px rgba(0, 0, 0, 0.44),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  .orb-medallion svg {
    width: 28px;
    height: 28px;
    display: block;
    pointer-events: none;
    transition: transform 0.22s var(--ease);
  }

  .orb-medallion:hover,
  .orb-medallion:focus-visible {
    border-color: var(--border-strong);
    box-shadow:
      0 18px 36px -10px rgba(13, 18, 24, 0.2),
      0 4px 12px -2px rgba(13, 18, 24, 0.09);
    outline: none;
  }

  [data-theme="dark"] .orb-medallion:hover,
  [data-theme="dark"] .orb-medallion:focus-visible {
    background: #1e232c;
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow:
      0 18px 40px -8px rgba(0, 0, 0, 0.78),
      0 4px 14px -2px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  .orb-medallion:focus-visible {
    box-shadow:
      0 0 0 2.5px var(--background),
      0 0 0 4.5px var(--brand);
  }

  .orb-medallion:hover svg {
    transform: scale(1.06);
  }

  /* Active Selected Medallion — tactile hairline + soft editorial ring */
  .orb-medallion[aria-pressed="true"] {
    border-color: var(--brand);
    background: color-mix(in oklab, var(--brand) 6%, #ffffff);
    box-shadow:
      0 0 0 3px var(--brand-soft),
      0 14px 30px -8px rgba(13, 18, 24, 0.16);
  }

  [data-theme="dark"] .orb-medallion[aria-pressed="true"] {
    border-color: var(--brand);
    background: color-mix(in oklab, var(--brand) 14%, #171b22);
    box-shadow:
      0 0 0 3px var(--brand-soft),
      0 16px 36px -8px rgba(0, 0, 0, 0.72),
      inset 0 1px 0 rgba(255, 255, 255, 0.11);
  }

  /* Single Floating Tooltip Layer (always crisp above card & medallions) */
  .orb-tooltip {
    display: flex;
    align-items: center;
    gap: 0.36rem;
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 8;
    pointer-events: none;
    padding: 0.34rem 0.72rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--popover);
    color: var(--popover-foreground);
    font-size: 0.77rem;
    font-weight: 560;
    letter-spacing: -0.008em;
    white-space: nowrap;
    box-shadow:
      0 10px 26px -8px rgba(13, 18, 24, 0.18),
      0 2px 6px -1px rgba(13, 18, 24, 0.08);
    opacity: 0;
    transition: opacity 0.15s var(--ease);
  }

  [data-theme="dark"] .orb-tooltip {
    background: #1d2129;
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow:
      0 14px 32px -6px rgba(0, 0, 0, 0.72),
      inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  .orb-tooltip.is-visible {
    opacity: 1;
  }

  .orb-tooltip-sub {
    color: var(--muted-foreground);
    font-weight: 460;
  }

  /* Quiet Bottom-Right Pause / Play Control — borderless until hovered */
  .orb-toggle {
    display: grid;
    place-items: center;
    position: absolute;
    right: 0.25rem;
    bottom: 0.35rem;
    z-index: 6;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--muted-foreground);
    opacity: 0.52;
    cursor: pointer;
    box-shadow: none;
    transition:
      opacity 0.16s var(--ease),
      background-color 0.16s var(--ease),
      color 0.16s var(--ease),
      transform 0.18s var(--ease);
  }

  [data-theme="dark"] .orb-toggle {
    background: transparent;
    border: 0;
    color: var(--muted-foreground);
    box-shadow: none;
  }

  .orb-toggle:hover {
    opacity: 1;
    background: var(--surface);
    color: var(--foreground);
    transform: scale(1.04);
  }

  .orb-toggle:active {
    transform: scale(0.95);
  }

  .orb-toggle:focus-visible {
    opacity: 1;
    outline: 2px solid var(--ring);
    outline-offset: 2px;
  }

  .orb-toggle svg {
    width: 0.78rem;
    height: 0.78rem;
    display: block;
  }

  /* Quiet Borderless Subject + Card Type Switcher Under the Card */
  #practice .ex-rail {
    order: 2;
    position: static;
    top: auto;
    width: 100%;
    max-width: 52rem;
    padding: 0.2rem 0 0;
    border: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.68rem;
    text-align: center;
  }

  #practice .ex-rail-group {
    width: 100%;
    align-items: center;
    gap: 0;
  }

  #practice .ex-rail-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  #practice .ex-rail .pill-tabs {
    justify-content: center;
    gap: 1.5rem;
  }

  #practice .ex-rail .pill-tabs button {
    padding: 0.2rem 0 0.42rem;
    font-size: 0.86rem;
    font-weight: 500;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted-foreground);
    box-shadow: inset 0 -1.5px 0 transparent;
    transition: color 0.16s var(--ease), box-shadow 0.18s var(--ease);
  }

  #practice .ex-rail .pill-tabs button:hover {
    background: transparent;
    color: var(--foreground);
  }

  #practice .ex-rail .pill-tabs button[aria-selected="true"] {
    background: transparent;
    color: var(--foreground);
    font-weight: 600;
    box-shadow: inset 0 -1.5px 0 var(--foreground);
  }

  #practice .ex-rail .ex-chips {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }

  #practice .ex-rail .ex-chip {
    text-align: center;
    padding: 0.28rem 0.78rem;
    border-radius: var(--radius-pill);
    border: 0;
    background: transparent;
    font-size: 0.81rem;
    font-weight: 480;
    color: var(--muted-foreground);
  }

  #practice .ex-rail .ex-chip:hover {
    background: var(--surface);
    color: var(--foreground);
  }

  #practice .ex-rail .ex-chip[aria-selected="true"] {
    background: var(--surface-hover);
    border: 0;
    color: var(--foreground);
    font-weight: 580;
  }

  #practice .ex-desc {
    display: none;
  }

  /* 3 Editorial Columns Below — clean breathing room, no extra divider */
  #practice .tri-cols {
    margin-top: clamp(2.4rem, 4vw, 3.2rem);
    padding-top: 0;
    border-top: 0;
  }
}

/* ----------------------------------------------------- Mobile & Tablet Polish (<= 959px) */
@media (max-width: 959px) {
  #practice .sec-head-left {
    text-align: left;
    justify-content: flex-start;
  }

  #practice .sec-head-left > div {
    margin-inline: 0;
  }

  #practice .sec-lead {
    margin-inline: 0;
  }

  #practice .ex-stage {
    border-radius: 18px;
    padding: 0.9rem 0.9rem 0.8rem;
  }

  #practice .ex-foot {
    gap: 0.5rem;
  }

  #practice .ex-foot .btn {
    padding: 0 0.9rem;
    font-size: 0.83rem;
  }
}

@media (max-width: 420px) {
  #practice .ex-stage {
    padding: 0.8rem 0.75rem 0.75rem;
    border-radius: 16px;
  }
}

/* ----------------------------------------------------- Medallion Icon Theme Tokens */
.orb-medallion {
  --ic-ink: #17191d;
  --ic-muted: rgba(23, 25, 29, 0.34);
  --ic-soft: rgba(23, 25, 29, 0.08);
  --ic-teal: #3d8973;
  --ic-amber: #b87314;
  --ic-blue: #2f6db8;
  --ic-indigo: #4d55a6;
  --ic-rose: #b84a39;
  --ic-emerald: #2a7f5f;
  --ic-ocean: #3c7d8a;
  --ic-vermilion: #b5382a;
}

[data-theme="dark"] .orb-medallion {
  --ic-ink: #eef1f5;
  --ic-muted: rgba(238, 241, 245, 0.36);
  --ic-soft: rgba(238, 241, 245, 0.11);
  --ic-teal: #6eb8a3;
  --ic-amber: #e5b34e;
  --ic-blue: #7aaef0;
  --ic-indigo: #9ea5f2;
  --ic-rose: #ea8676;
  --ic-emerald: #5cc49a;
  --ic-ocean: #7db0b3;
  --ic-vermilion: #eb786a;
}

/* Stable vertical centering: fixed comfortable arena height prevents scroll jumps & crowding */
.ex-playground.is-orbital,
.ex-playground.is-orbital .orb-arena {
  overflow-anchor: none;
}
@media (min-width: 960px) {
  .ex-playground.is-orbital .orb-arena {
    height: clamp(27.5rem, 56vh, 31.5rem);
    min-height: 27.5rem;
  }
}

/* Reduced motion: soften any hover micro-transitions */
@media (prefers-reduced-motion: reduce) {
  .orb-medallion,
  .orb-medallion svg,
  .orb-tooltip,
  .orb-toggle {
    transition: none;
  }
}
