:root {
  --phonetics-ink: #18353e;
  --phonetics-deep: #244b58;
  --phonetics-lime: #d9f58a;
  --phonetics-paper: #f7f7f1;
}

.phonetics-page { overflow-x: hidden; background: var(--phonetics-paper); color: var(--phonetics-ink); }

.home-phonetics {
  /* Allow child cards/preview shadows and rounded corners to be visible */
  overflow: visible;
  padding: 72px 24px 78px;
  background:
    radial-gradient(circle at 8% 8%, rgba(217, 245, 138, .16), transparent 28%),
    #f0f4f1;
  color: var(--phonetics-ink);
}
.home-phonetics-inner { width: min(1160px, 100%); max-width: 100%; min-width: 0; margin: 0 auto; }
.home-phonetics .home-section-head { width: 100%; margin-bottom: 36px; }
.home-phonetics .phonetics-layout,
.home-phonetics .phonetics-groups,
.home-phonetics .phonetic-group,
.home-phonetics .phonetic-preview { max-width: 100%; min-width: 0; }

.phonetics-hero {
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at 78% 18%, rgba(217, 245, 138, .22) 0 10%, transparent 35%),
    var(--phonetics-deep);
  color: #fff;
}
.phonetics-hero-inner,
.phonetics-main { width: min(1180px, 100%); margin: 0 auto; }
.phonetics-hero-inner { display: flex; min-height: 86px; align-items: center; justify-content: space-between; gap: 40px; }
.phonetics-eyebrow,
.phonetic-preview-label { display: flex; align-items: center; gap: 10px; font-size: .72rem; font-weight: 700; letter-spacing: .18em; }
.phonetics-eyebrow { margin-bottom: 8px; color: var(--phonetics-lime); }
.phonetics-eyebrow span,
.phonetic-preview-label span { width: 28px; height: 2px; background: currentColor; }
.phonetics-hero h1 { margin: 0; font-size: clamp(2.25rem, 4vw, 3.8rem); line-height: 1; letter-spacing: -.04em; }
.phonetics-hero h1::after { content: '/fəˈnetɪks/'; margin-left: 18px; color: var(--phonetics-lime); font-family: Georgia, serif; font-size: .2em; font-weight: 400; letter-spacing: 0; }
.phonetics-hero p:last-child { max-width: 650px; margin-top: 10px; color: rgba(255,255,255,.68); font-size: .88rem; }
.phonetics-progress { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.phonetics-progress strong { color: var(--phonetics-lime); font: 700 clamp(3.3rem, 6vw, 5rem)/.8 Georgia, serif; }
.phonetics-progress span { color: rgba(255,255,255,.66); font-size: .78rem; line-height: 1.5; text-transform: uppercase; letter-spacing: .08em; }

.phonetics-main { padding: 22px 24px 42px; }
.phonetics-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 16px; }
.phonetics-section-index { margin-bottom: 8px; color: #78909a; font-size: .7rem; font-weight: 700; letter-spacing: .18em; }
.phonetics-intro h2 { font-size: clamp(1.45rem, 2vw, 1.8rem); line-height: 1.2; }
.phonetics-intro > p { max-width: 500px; color: #70828a; font-size: .9rem; text-align: right; }
.phonetics-layout { display: grid; width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: stretch; }
.phonetics-groups { display: grid; width: 100%; min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.phonetic-group { --group-accent: #bedc67; overflow: hidden; min-width: 0; border: 1px solid rgba(24,53,62,.1); border-radius: 18px; background: #fff; box-shadow: 0 12px 34px rgba(34,64,75,.06); }
.phonetic-group-b { --group-accent: #76c9bf; }
.phonetic-group-c { --group-accent: #f2bb69; }
.phonetic-group-d { --group-accent: #b7a9e8; }
.phonetic-group header { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 12px; border-bottom: 1px solid rgba(24,53,62,.08); }
.phonetic-group header > div { min-width: 0; }
.phonetic-group-number { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--group-accent) 30%, white); color: var(--phonetics-ink); font: 700 .65rem/1 var(--font-mono); }
.phonetic-group h3 { font-size: .85rem; line-height: 1.3; }
.phonetic-group header p { margin-top: 2px; color: #8a9aa0; font-size: .68rem; letter-spacing: .04em; }
.phonetic-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; padding: 1px; background: rgba(24,53,62,.08); }
.phonetic-key { position: relative; min-width: 0; min-height: 58px; border: 0; background: #fff; color: var(--phonetics-ink); cursor: pointer; transition: color .15s, background .15s, transform .15s; -webkit-tap-highlight-color: transparent; }
.phonetic-key span { font: 500 clamp(1.25rem, 2vw, 1.65rem)/1.1 'Arial Unicode MS', 'Noto Sans', Arial, sans-serif; }
.phonetic-key:hover { z-index: 1; background: color-mix(in srgb, var(--group-accent) 16%, white); }
.phonetic-key:focus-visible { z-index: 2; outline: 3px solid var(--group-accent); outline-offset: -3px; }
.phonetic-key.is-active { z-index: 1; background: var(--group-accent); color: #102b33; }
.phonetic-key.is-active::after { content: ''; position: absolute; right: 8px; bottom: 8px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.phonetic-key.is-pending { color: #829198; }
.phonetic-key.is-pending::before { content: '待补'; position: absolute; top: 3px; right: 4px; padding: 1px 3px; border: 1px solid currentColor; border-radius: 5px; font: 600 .44rem/1.2 var(--font-sans); letter-spacing: 0; opacity: .72; }
.phonetic-key.is-audio-only::before { content: '拼读'; position: absolute; top: 3px; right: 4px; padding: 1px 3px; border: 1px solid #a96a18; border-radius: 5px; color: #8a5716; font: 600 .44rem/1.2 var(--font-sans); letter-spacing: 0; opacity: .85; }

.phonetic-preview { position: sticky; top: calc(var(--nav-h) + 20px); overflow: hidden; min-height: 0; padding: 22px; border-radius: 18px; background: var(--phonetics-deep); color: #fff; box-shadow: 0 18px 50px rgba(21,48,58,.18); z-index: 1; }
.phonetic-preview::after { content: ''; position: absolute; top: -100px; right: -90px; width: 230px; height: 230px; border: 1px solid rgba(217,245,138,.2); border-radius: 50%; }
.phonetic-preview-label { position: relative; z-index: 1; color: var(--phonetics-lime); font-size: .62rem; }
.phonetic-preview-group { margin-top: 20px; color: rgba(255,255,255,.55); font-size: .72rem; letter-spacing: .15em; }
.phonetic-preview-symbol { margin: 4px 0 8px; color: var(--phonetics-lime); font: 700 3.7rem/1 'Arial Unicode MS', 'Noto Sans', Arial, sans-serif; letter-spacing: -.05em; }
.phonetic-preview h2 { font-size: 1.25rem; }
.phonetic-example { min-height: 112px; }
.phonetic-word-ipa { margin-top: -2px; color: var(--phonetics-lime); font: 500 1rem/1.4 'Arial Unicode MS', 'Noto Sans', Arial, sans-serif; }
.phonetic-sentence { margin-top: 8px; color: rgba(255,255,255,.9); font-size: .84rem; line-height: 1.35; }
.phonetic-sentence-ipa { margin-top: 4px; color: rgba(255,255,255,.5); font: 400 .72rem/1.4 'Arial Unicode MS', 'Noto Sans', Arial, sans-serif; }
.phonetic-mouth-placeholder { position: relative; display: grid; overflow: hidden; min-height: 112px; margin-top: 10px; place-items: center; border: 1px solid rgba(217,245,138,.28); border-radius: 13px; background: rgba(255,255,255,.04); color: rgba(255,255,255,.42); font-size: .68rem; letter-spacing: .12em; }
.phonetic-mouth-placeholder video { width: 100%; height: 112px; object-fit: cover; }
.phonetic-mouth-empty { display: grid; position: absolute; inset: 0; place-items: center; align-content: center; gap: 5px; }
.phonetic-mouth-empty svg { width: 54px; fill: none; stroke: var(--phonetics-lime); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; opacity: .62; }
.phonetic-preview-foot { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.42); font-size: .67rem; }
.phonetic-preview-foot b { color: var(--phonetics-lime); font-family: var(--font-mono); }

@media (max-width: 980px) {
  .phonetics-layout { grid-template-columns: minmax(0, 1fr); }
  /* Keep preview as a positioned container so its absolute ::after is clipped */
  .phonetic-preview { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 180px); column-gap: 24px; min-height: 0; }
  
  /* Ensure the whole phonetics main area sits above following sections on mobile */
  .phonetics-main { position: relative; z-index: 1; padding-bottom: 40px; }
  /* Add extra bottom spacing so following sections do not visually overlap rounded preview */
  .phonetic-preview { margin-bottom: 18px; }
  .phonetic-preview-label, .phonetic-preview-group, .phonetic-preview-symbol, .phonetic-preview h2, .phonetic-preview-copy, .phonetic-preview-foot { grid-column: 1; }
  .phonetic-example { grid-column: 1; }
  .phonetic-mouth-placeholder { grid-column: 2; grid-row: 1 / 7; margin: 0; }
  /* Reduce vertical spacing between groups and preview on mobile */
  .phonetics-layout { row-gap: 6px; gap: 6px 24px; }
}

@media (max-width: 720px) {
  .home-phonetics { padding: 20px 8px 28px; }
  .home-phonetics .home-section-head { display: block; margin-bottom: 10px; padding: 0 10px; }
  .home-phonetics .home-section-index { display: none; }
  .home-phonetics .home-section-head > div { margin-top: 0; }
  .home-phonetics .home-section-head h2 { font-size: 1.55rem; line-height: 1.15; }
  .home-phonetics .home-section-head > div > p { margin-top: 5px; font-size: .68rem; line-height: 1.45; }
  .phonetics-hero { padding: 13px 16px; }
  .phonetics-hero-inner { min-height: 62px; }
  .phonetics-hero-inner { align-items: flex-start; }
  .phonetics-progress { display: none; }
  .phonetics-eyebrow { margin-bottom: 5px; font-size: .58rem; }
  .phonetics-hero h1 { font-size: 1.8rem; }
  .phonetics-hero h1::after { margin-left: 9px; font-size: .42em; }
  .phonetics-hero p:last-child { display: none; }
  .phonetics-main { padding: 10px 8px 24px; }
  .phonetics-intro { align-items: center; margin-bottom: 8px; }
  .phonetics-section-index { display: none; }
  .phonetics-intro h2 { font-size: 1rem; }
  .phonetics-intro > p { max-width: 265px; font-size: .65rem; line-height: 1.45; text-align: right; }
  .phonetics-layout { gap: 8px; }
  .phonetics-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .phonetic-group { border-radius: 10px; }
  .phonetic-group header { min-height: 37px; gap: 6px; padding: 4px 6px; }
  .phonetic-group-number { width: 24px; height: 24px; font-size: .54rem; }
  .phonetic-group h3 { overflow: hidden; max-width: 100%; font-size: .64rem; text-overflow: ellipsis; white-space: nowrap; }
  .phonetic-group header p { display: none; }
  .phonetic-key { min-height: clamp(35px, 10vw, 43px); }
  .phonetic-key span { font-size: clamp(.88rem, 4.4vw, 1.18rem); }
  .phonetic-key.is-active::after { right: 4px; bottom: 4px; width: 3px; height: 3px; }
  .phonetic-key.is-pending::before { top: 2px; right: 2px; padding: 0 2px; font-size: .38rem; }
  .phonetic-key.is-audio-only::before { top: 2px; right: 2px; padding: 0 2px; font-size: .38rem; }
  /* Make mouth/video column wider on small screens and responsive using clamp() */
  .phonetic-preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, clamp(160px, 30vw, 260px)); column-gap: 12px; padding: 12px 14px; border-radius: 12px; }
  .phonetic-preview-label { font-size: .52rem; }
  .phonetic-preview-group { margin-top: 5px; font-size: .58rem; }
  .phonetic-preview-symbol { margin: 1px 0 3px; font-size: 2.55rem; }
  .phonetic-preview h2 { font-size: .86rem; }
  .phonetic-example { grid-column: 1; min-height: 0; }
  .phonetic-word-ipa { font-size: .72rem; line-height: 1.25; }
  .phonetic-sentence { margin-top: 3px; font-size: .64rem; line-height: 1.25; }
  .phonetic-sentence-ipa { margin-top: 2px; font-size: .55rem; line-height: 1.25; }
  .phonetic-mouth-placeholder { grid-column: 2; grid-row: 1 / 7; min-height: 118px; margin: 0; }
  /* Ensure the mouth video is fully visible (no cropping) on small screens */
  .phonetic-mouth-placeholder video { height: 100%; min-height: 118px; object-fit: contain; }
  .phonetic-mouth-empty svg { width: 45px; }
  .phonetic-preview-foot { margin-top: 6px; padding-top: 5px; font-size: .56rem; }
}

/* Hide decorative ring on mobile widths to avoid visible quarter-circle */
@media (max-width: 980px) {
  .phonetic-preview::after { display: none; }
}

@media (max-width: 520px) {
  .phonetic-preview { display: grid; }
  .phonetic-mouth-placeholder { min-height: 118px; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .phonetic-key { transition: none; }
}
