/* ── Super Sentences overlay styles ── */
/* Adapted from atomic-english study panel */

/* ── Variables ── */

:root {
  --ss-ink: #171819;
  --ss-muted: #6f737a;
  --ss-pencil: rgba(60, 65, 72, 0.18);
  --ss-pencil-dark: rgba(40, 45, 52, 0.72);
  --ss-red: rgba(231, 76, 60, 0.25);
}

/* ── Overlay ── */

.ss-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  pointer-events: none;
  opacity: 0;
}

.ss-overlay.is-active {
  pointer-events: auto;
  opacity: 1;
}

.ss-overlay.is-leaving {
  pointer-events: none;
  opacity: 0;
  transition: opacity 360ms ease;
}

body.ss-open .container,
body.ss-open .promo-pill {
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

/* ── Card ── */

.ss-card {
  position: relative;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  margin: 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, #f5f0eb 0%, #ede8f5 50%, #e8f0f2 100%);
  box-shadow: 0 4px 24px rgba(8, 0, 138, 0.18), 0 0 0 1px rgba(8, 0, 138, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ss-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 18px;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(170, 180, 195, 0.06) 3px, rgba(170, 180, 195, 0.06) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(170, 180, 195, 0.06) 3px, rgba(170, 180, 195, 0.06) 4px);
  z-index: 0;
}

/* ── Close button ── */

.ss-close {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 110;
  width: 40px;
  height: 40px;
  border: 1.5px solid rgba(8, 0, 138, 0.15);
  background: #fdfaf6;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: #6f737a;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 150ms ease, border-color 150ms ease, opacity 200ms ease;
  box-shadow: 0 2px 8px rgba(8, 0, 138, 0.1);
}

.ss-close:hover {
  background: #fff;
  border-color: rgba(8, 0, 138, 0.3);
}

body.ss-panel-open .ss-close {
  opacity: 0;
  pointer-events: none;
}

/* ── Rail (progress bar only, no dots) ── */

.ss-rail {
  position: relative;
  padding: 48px 0 0;
  flex-shrink: 0;
  z-index: 5;
}

.ss-rail-progress {
  width: 100%;
  height: 1px;
  position: relative;
  background: rgba(0, 0, 0, 0.04);
}

.ss-rail-progress-fill {
  position: absolute;
  top: -7px;
  left: 0;
  width: 0%;
  height: 16px;
  background: var(--ss-red);
  filter: blur(10px);
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.ss-rail-inner {
  display: none;
}

/* ── Panel body ── */

.ss-panel-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ss-study-section {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr;
  place-items: center;
}

.ss-study-content {
  position: relative;
  z-index: 2;
  width: min(980px, 100%);
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto auto;
  align-items: center;
  padding: clamp(20px, 4vw, 44px);
}

/* ── Sentence ── */

.ss-sentence-wrap {
  position: relative;
  width: min(860px, 100%);
  margin: 0 auto;
}

.ss-sentence {
  max-width: 100%;
  min-height: 0;
  margin: 0 auto;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 5.2vw, 58px);
  line-height: 1.22;
  text-align: center;
}

.ss-sentence.is-wrong {
  animation: ssNudge 230ms ease both;
}

/* ── Sentence words ── */

.ss-sentence-word,
.ss-gap {
  color: rgba(23, 24, 25, 0.32);
  transition: color 180ms ease, background 220ms ease, transform 220ms ease, opacity 220ms ease;
}

.ss-sentence-word.has-spoken,
.ss-sentence-word.is-speaking {
  color: rgba(33, 29, 24, 0.95);
}

.ss-sentence-word.is-speaking {
  color: rgba(33, 29, 24, 0.95);
  text-shadow: none;
}

/* ── Gap ── */

.ss-gap {
  display: inline-block;
  min-width: 2.65em;
  height: 1em;
  border: 0;
  border-bottom: 2px solid rgba(23, 24, 25, 0.16);
  border-radius: 0;
  text-align: center;
  vertical-align: baseline;
}

.ss-gap.is-filled {
  display: inline;
  min-width: auto;
  height: auto;
  border-bottom: none;
  padding-bottom: 0;
  color: #05007b;
  animation: ssFillPop 340ms ease both;
}

.ss-gap.is-filled .ss-sentence-word {
  color: rgba(33, 29, 24, 0.24);
}

.ss-gap.is-filled .ss-sentence-word.has-spoken {
  color: #05007b;
}

.ss-gap.is-filled .ss-sentence-word.is-speaking {
  color: rgba(33, 29, 24, 0.95);
}

/* ── Controls (replay, meaning, mute) ── */

.ss-controls {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin: 0 auto 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 30px;
  z-index: 3;
  opacity: 1;
  animation: ssControlsFade 260ms ease both;
}

.ss-controls[hidden] {
  visibility: hidden;
  display: flex;
}

.ss-controls button {
  display: grid;
  place-items: center;
  width: clamp(32px, 5vw, 40px);
  height: clamp(32px, 5vw, 40px);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(23, 24, 25, 0.58);
  box-shadow: 0 6px 18px rgba(23, 24, 25, 0.06);
  cursor: pointer;
  transition: color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.ss-controls button:hover {
  color: rgba(23, 24, 25, 0.94);
  transform: translateY(-1px);
}

.ss-controls svg {
  width: clamp(15px, 2.5vw, 19px);
  height: clamp(15px, 2.5vw, 19px);
  stroke-width: 1.85;
}

/* ── Choice area ── */

.ss-choice-area {
  position: relative;
  width: 100%;
  padding-bottom: 24px;
}

/* ── Choices ── */

.ss-choice-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  margin-top: clamp(30px, 6vh, 64px);
  align-self: start;
}

.ss-choice-row button,
.ss-next-btn {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #1f2226;
  box-shadow: none;
  cursor: pointer;
  font: 600 clamp(18px, 2vw, 23px)/1.1 Georgia, "Times New Roman", serif;
  padding: 8px 10px;
  text-decoration: underline;
  text-decoration-color: rgba(23, 24, 25, 0.18);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
  transition: color 160ms ease, opacity 160ms ease, text-decoration-color 160ms ease;
}

.ss-choice-row button:disabled {
  cursor: default;
}

.ss-choice-row button.is-correct {
  color: #171819;
  text-decoration-color: transparent;
}

.ss-choice-row button.is-wrong {
  opacity: 0.44;
  text-decoration-color: rgba(23, 24, 25, 0.06);
}

/* ── Next button ── */

.ss-next-btn {
  min-width: 120px;
  font-family: Georgia, "Times New Roman", serif !important;
  font-weight: 600 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #1f2226 !important;
  text-decoration: underline !important;
  text-decoration-color: rgba(23, 24, 25, 0.18) !important;
  text-decoration-thickness: 1px !important;
  text-underline-offset: 0.28em !important;
  box-shadow: none !important;
  backdrop-filter: none;
}

/* ── Completion view ── */

.ss-complete-view {
  display: none;
  text-align: center;
  padding: 0 20px;
  place-self: center;
}

.ss-complete-view.show {
  display: block;
}

.ss-complete-view h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 7vw, 56px);
  font-weight: 500;
  margin: 0 0 16px;
}

.ss-complete-view p {
  color: var(--ss-muted);
  font-size: 1.1rem;
  margin: 0 0 24px;
}

/* ── Meaning panel (bottom sheet) ── */

.ss-meaning-panel {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 120;
  display: grid;
  gap: 18px;
  width: min(760px, calc(100vw - 20px));
  max-height: min(72vh, 540px);
  overflow: auto;
  border: 1px solid rgba(29, 31, 36, 0.12);
  border-radius: 24px;
  background: rgba(250, 250, 249, 0.96);
  padding: 14px 26px 26px;
  color: #43464d;
  font-size: 17px;
  line-height: 1.45;
  box-shadow: 0 24px 80px rgba(22, 24, 29, 0.18);
  backdrop-filter: blur(20px) saturate(1.04);
  transform: translateX(-50%);
  animation: ssSheetIn 220ms ease both;
}

.ss-meaning-panel[hidden] {
  display: none;
}

.ss-meaning-panel p {
  margin: 0;
}

.ss-meaning-handle {
  width: 44px;
  height: 4px;
  margin: 2px auto 0;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.14);
}

.ss-meaning-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}

.ss-meaning-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ss-muted);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 160ms ease;
}

.ss-meaning-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.ss-study-help {
  color: rgba(23, 24, 25, 0.86);
  max-width: calc(100% - 72px);
  padding-top: 8px;
}

.ss-study-help strong {
  color: transparent;
  background:
    radial-gradient(ellipse 145% 86% at 56% 54%, rgba(175, 124, 214, 0.98), rgba(138, 91, 181, 0.94) 54%, rgba(88, 65, 110, 0.9) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  font-weight: 650;
}

.ss-translation-content {
  border-top: 1px solid rgba(22, 24, 29, 0.08);
  padding-top: 2px;
}

.ss-translation {
  color: rgba(23, 24, 25, 0.68);
  font-weight: 520;
}

.ss-lang-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  gap: 8px;
  border: 1px solid rgba(22, 24, 29, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  padding: 8px 10px;
  color: #60646c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font: 500 14px/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ss-lang-select {
  min-width: 92px;
  max-width: 150px;
  border: 0;
  background: transparent;
  color: #191b20;
  font: inherit;
  padding: 0 18px 0 0;
  cursor: pointer;
}

/* ── Animations ── */

@keyframes ssNudge {
  0% { transform: translateX(0); }
  24% { transform: translateX(-8px); }
  48% { transform: translateX(7px); }
  72% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

@keyframes ssFillPop {
  0% { opacity: 0.18; transform: scale(0.96); filter: blur(2px); }
  58% { opacity: 1; transform: scale(1.028); filter: blur(0); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes ssRailArrive {
  0% { opacity: 0; transform: scale(0.86); }
  64% { opacity: 1; transform: scale(1.055); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes ssControlsFade {
  0% { opacity: 0; transform: translateY(2px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes ssSheetIn {
  0% { opacity: 0; transform: translate(-50%, 18px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  .ss-overlay,
  .ss-panel,
  .ss-sentence,
  .ss-study-content {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Mobile ── */

@media (max-width: 640px) {
  .ss-rail {
    padding: 36px 0 0;
  }

  .ss-sentence {
    font-size: clamp(24px, 7vw, 36px);
  }

  .ss-choice-row {
    margin-top: clamp(20px, 4vh, 40px);
  }

  .ss-meaning-panel {
    width: calc(100vw - 16px);
    left: 8px;
    transform: none;
    border-radius: 20px 20px 0 0;
  }
}

audio { display: none; }
