/* Vocalwarmup — calm, clean, mobile-first. No framework. */

:root {
  --bg: #f4f1ea;          /* warm paper */
  --surface: #ffffff;
  --ink: #1f2933;          /* soft near-black */
  --ink-soft: #5b6670;
  --accent: #4a7c74;       /* calm teal-green */
  --accent-soft: #e3ece9;
  --border: #e2ddd3;
  --shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
  --radius: 20px;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b1f;
    --surface: #1f262b;
    --ink: #eef1f3;
    --ink-soft: #9aa5ad;
    --accent: #6fb3a7;
    --accent-soft: #243430;
    --border: #2c353b;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overscroll-behavior: none;
}

.app-header {
  padding: calc(env(safe-area-inset-top) + 14px) 20px 10px;
  text-align: center;
}
.app-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.view {
  display: none;
  height: 100%;
  padding: 8px 20px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  flex-direction: column;
}
.view.is-active { display: flex; }

/* ---------- Practice ---------- */

.practice-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 6px 14px;
}
.group-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}
.card-progress {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.card {
  flex: 1;
  perspective: 1400px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  min-height: 0;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}
.card.is-flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 24px;
}
.card-back { transform: rotateY(180deg); background: var(--accent-soft); }

.twister-text {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
  /* scales with viewport but stays readable */
  font-size: clamp(1.8rem, 7vw, 3.2rem);
  /* fill the (centered) flex line so text wraps instead of overflowing */
  width: 100%;
  max-width: 20ch;
  overflow-wrap: break-word;
}

.back-group {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
}
.back-cue {
  margin: 0;
  font-size: clamp(1.1rem, 4.5vw, 1.6rem);
  line-height: 1.4;
  color: var(--ink);
  width: 100%;
  max-width: 30ch;
  overflow-wrap: break-word;
}

.flip-hint {
  position: absolute;
  bottom: 16px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  opacity: 0.7;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 18px;
}
.nav-btn {
  width: 64px;
  height: 56px;
  font-size: 1.8rem;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.nav-btn:active { transform: translateY(1px); }
.shuffle-btn {
  flex: 1;
  height: 56px;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.shuffle-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------- Videos ---------- */

#videos { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.videos-intro {
  margin: 4px 6px 16px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.video-list { list-style: none; margin: 0; padding: 0; }
.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.video-card.pinned { border-color: var(--accent); }

.video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  padding: 0;
  cursor: pointer;
  background: #000;
  display: block;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-badge {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
}
.video-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }

.video-info { padding: 12px 16px 14px; }
.video-title { font-weight: 600; font-size: 1.05rem; }
.video-part { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
.start-here {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  padding: 3px 9px;
  border-radius: 999px;
}

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
}
.tab .tab-icon { font-size: 1.3rem; filter: grayscale(0.4); opacity: 0.6; }
.tab.is-active { color: var(--accent); }
.tab.is-active .tab-icon { filter: none; opacity: 1; }
