/* ---------------------------------------------------------------------------
   Duolinguoish — one stylesheet for both shells (PWA tab + extension popup).
   The `.is-popup` body class on popup.html tightens spacing; everything else
   is shared.
   --------------------------------------------------------------------------- */

:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --green-soft: #d7ffb8;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --red-soft: #ffdfe0;
  --yellow: #ffc800;
  --purple: #ce82ff;
  --orange: #ff9600;

  --bg: #ffffff;
  --bg-alt: #f7f7f7;
  --card: #ffffff;
  --text: #3c3c3c;
  --muted: #afafaf;
  --border: #e5e5e5;
  --border-strong: #d0d0d0;

  --radius: 16px;
  --shadow-depth: 4px;
  --maxw: 640px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131f24;
    --bg-alt: #0f181c;
    --card: #1c2b33;
    --text: #f1f7fb;
    --muted: #7b8f9a;
    --border: #37464f;
    --border-strong: #46626f;
    --green-soft: #202f36;
    --red-soft: #33191c;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body.is-popup {
  width: 400px;
  height: 580px;
  overflow: hidden;
}

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.is-popup .app {
  height: 580px;
  min-height: 0;
}

button {
  font-family: inherit;
}

/* ------------------------------- buttons ---------------------------------- */

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  cursor: pointer;
  color: #fff;
  background: var(--green);
  box-shadow: 0 var(--shadow-depth) 0 var(--green-dark);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.12s ease;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(var(--shadow-depth));
  box-shadow: 0 0 0 var(--green-dark);
}

.btn:disabled {
  background: var(--border);
  color: var(--muted);
  box-shadow: 0 var(--shadow-depth) 0 var(--border-strong);
  cursor: not-allowed;
}

.btn--blue {
  background: var(--blue);
  box-shadow: 0 var(--shadow-depth) 0 var(--blue-dark);
}
.btn--blue:active:not(:disabled) {
  box-shadow: 0 0 0 var(--blue-dark);
}

.btn--red {
  background: var(--red);
  box-shadow: 0 var(--shadow-depth) 0 var(--red-dark);
}
.btn--red:active:not(:disabled) {
  box-shadow: 0 0 0 var(--red-dark);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border: 2px solid var(--border);
}
.btn--ghost:active:not(:disabled) {
  transform: none;
  box-shadow: none;
  background: var(--bg-alt);
}

.btn--wide {
  width: 100%;
}

.btn--sm {
  padding: 9px 14px;
  font-size: 13px;
  --shadow-depth: 3px;
}

/* -------------------------------- header ---------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.topbar__brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--green);
  letter-spacing: -0.4px;
  margin-right: auto;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
}

.stat--streak {
  color: var(--orange);
}
.stat--xp {
  color: var(--yellow);
}
.stat--hearts {
  color: var(--red);
}
.stat--dim {
  color: var(--muted);
}

/* ------------------------------- layout ----------------------------------- */

.screen {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen--flush {
  padding: 0;
  gap: 0;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 -4px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}

/* ----------------------------- track cards -------------------------------- */

.track-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}

.track-card:hover {
  background: var(--bg-alt);
}

.track-card__icon {
  font-size: 30px;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--bg-alt);
}

.track-card__body {
  flex: 1;
  min-width: 0;
}

.track-card__title {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 3px;
}

.track-card__sub {
  font-size: 13px;
  color: var(--muted);
}

/* ------------------------------ progress bar ------------------------------ */

.bar {
  height: 12px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 0.3s ease;
}

.bar--thin {
  height: 8px;
}

/* -------------------------------- unit path ------------------------------- */

.unit {
  padding: 18px;
  border-bottom: 2px solid var(--border);
}

.unit__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  color: #fff;
  margin-bottom: 18px;
}

.unit__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.unit__head p {
  margin: 2px 0 0;
  font-size: 13px;
  opacity: 0.85;
}

.unit__crowns {
  margin-left: auto;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}

.path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.node {
  position: relative;
  width: 68px;
  height: 62px;
  border: none;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 6px 0 var(--green-dark);
  color: #fff;
  font-size: 25px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.node:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--green-dark);
}

.node--locked {
  background: var(--border);
  box-shadow: 0 6px 0 var(--border-strong);
  color: var(--muted);
  cursor: not-allowed;
}

.node--done {
  background: var(--yellow);
  box-shadow: 0 6px 0 #d9a900;
}

.node__label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

/* offsets give the path its wandering Duolingo feel */
.path__row {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
}
.path__row[data-offset="0"] { transform: translateX(0); }
.path__row[data-offset="1"] { transform: translateX(52px); }
.path__row[data-offset="2"] { transform: translateX(72px); }
.path__row[data-offset="3"] { transform: translateX(52px); }
.path__row[data-offset="4"] { transform: translateX(0); }
.path__row[data-offset="5"] { transform: translateX(-52px); }
.path__row[data-offset="6"] { transform: translateX(-72px); }
.path__row[data-offset="7"] { transform: translateX(-52px); }

/* -------------------------------- lesson ---------------------------------- */

.lesson-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
}

.icon-btn {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.prompt {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.35;
  margin: 0;
}

.prompt code,
.choice code,
.explain code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  text-align: left;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.4;
  border-radius: 14px;
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.choice:hover:not(:disabled) {
  background: var(--bg-alt);
}

.choice--selected {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
}

.choice--correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
}

.choice--wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red-dark);
}

.choice:disabled {
  cursor: default;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  outline: none;
}

.text-input:focus {
  border-color: var(--blue);
}

/* match exercise */
.match {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.match__col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match__col-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 4px;
}

.choice--match-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  min-height: 56px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.4;
  border-bottom-width: 4px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.choice__badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-block;
  margin-left: 8px;
  white-space: nowrap;
}

.choice--matched {
  opacity: 0.85;
  pointer-events: none;
  transform: scale(0.98);
}

.choice--matched.pair-1 {
  border-color: #58cc02 !important;
  background: rgba(88, 204, 2, 0.12) !important;
  color: #2b6e00 !important;
}

.choice--matched.pair-1 .choice__badge {
  background: #58cc02;
  color: #fff;
}

.choice--matched.pair-2 {
  border-color: #1cb0f6 !important;
  background: rgba(28, 176, 246, 0.12) !important;
  color: #005b8a !important;
}

.choice--matched.pair-2 .choice__badge {
  background: #1cb0f6;
  color: #fff;
}

.choice--matched.pair-3 {
  border-color: #ff4b4b !important;
  background: rgba(255, 75, 75, 0.12) !important;
  color: #8f0000 !important;
}

.choice--matched.pair-3 .choice__badge {
  background: #ff4b4b;
  color: #fff;
}

.choice--matched.pair-4 {
  border-color: #ffb703 !important;
  background: rgba(255, 183, 3, 0.15) !important;
  color: #704c00 !important;
}

.choice--matched.pair-4 .choice__badge {
  background: #ffb703;
  color: #000;
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.choice--wrong {
  animation: shakeWrong 0.4s ease-in-out;
}

/* footer verdict bar */
.footer {
  border-top: 2px solid var(--border);
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg);
}

.footer--correct {
  background: var(--green-soft);
  border-top-color: transparent;
}

.footer--wrong {
  background: var(--red-soft);
  border-top-color: transparent;
}

.verdict {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.verdict__mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  background: #fff;
}

.verdict__title {
  font-weight: 800;
  font-size: 17px;
}

.verdict--correct .verdict__title,
.verdict--correct .verdict__mark {
  color: var(--green-dark);
}

.verdict--wrong .verdict__title,
.verdict--wrong .verdict__mark {
  color: var(--red-dark);
}

.explain {
  font-size: 14px;
  line-height: 1.5;
  margin: 6px 0 0;
  color: inherit;
  opacity: 0.9;
}

/* ------------------------------- summary ---------------------------------- */

.summary {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
}

.summary__emoji {
  font-size: 64px;
}

.summary__title {
  font-size: 26px;
  font-weight: 800;
  color: var(--yellow);
  margin: 0;
}

.tiles {
  display: flex;
  gap: 12px;
  margin: 18px 0 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.tile {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 2px;
  min-width: 104px;
  overflow: hidden;
}

.tile__label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  padding: 4px;
  border-radius: 11px 11px 0 0;
}

.tile__value {
  font-size: 22px;
  font-weight: 800;
  padding: 10px 6px;
}

/* -------------------------------- progress -------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.kpi {
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: var(--radius);
  padding: 14px;
  background: var(--card);
}

.kpi__value {
  font-size: 24px;
  font-weight: 800;
}

.kpi__label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-top: 2px;
}

.heat {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.heat__cell {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--border);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.list-row__bar {
  flex: 1;
  max-width: 180px;
}

.field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.field label {
  flex: 1;
  font-weight: 600;
}

.field select,
.field input[type="number"] {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
}

.switch {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
  flex: 0 0 46px;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch[aria-checked="true"] {
  background: var(--green);
}

.switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

/* --------------------------------- misc ----------------------------------- */

.spacer {
  flex: 1;
}

.center-note {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px 20px;
  line-height: 1.6;
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

@keyframes pop {
  0% { transform: scale(0.94); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pop {
  animation: pop 0.16s ease-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
