@font-face { font-family: "Pacifico"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/pacifico-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/cormorant-garamond-latin-400-italic.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cormorant Garamond"; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/cormorant-garamond-latin-ext-400-italic.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 300; font-display: swap; src: url(fonts/jost-latin-300-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/jost-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/jost-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/cormorant-garamond-latin-500-normal.woff2) format("woff2"); }

:root {
  /* Vayuputra palette: deep purple, violet, and gold */
  --bg: #2d1747;
  --ink-d: #f6eefc;          /* text on the dark background */
  --muted-d: #b8a5cf;
  --line-d: rgba(255, 255, 255, .14);
  --chip-d: rgba(255, 255, 255, .08);
  --yellow: #f5b82e;
  --purple: #9d6bf2;
  --violet: #c6a6ff;

  --panel: #fffaf0;          /* cards */
  --ink: #24143a;
  --muted: #7a6a8c;
  --border: #ece2d0;

  --es: var(--yellow);
  --pt: var(--violet);
  --accent: var(--yellow);
  --accent-bg: var(--yellow);
  --accent-on: #24103a;
  --accent-card: #9a6400;
  --other-card: #6b2fc4;

  --easy: #2f8a55;
  --easy-soft: #e3f3e8;
  --medium: #c07d0c;
  --medium-soft: #fcefd2;
  --hard: #c0392b;
  --hard-soft: #fbe3df;
  --radius: 18px;
}
body.lang-pt {
  --accent: var(--violet);
  --accent-bg: var(--purple);
  --accent-on: #fff;
  --accent-card: #6b2fc4;
  --other-card: #9a6400;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(170, 120, 250, .45), transparent 62%),
    radial-gradient(700px 420px at 92% 4%, rgba(245, 184, 46, .16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink-d);
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 0 18px; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* header */
.top {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 18px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--yellow);
  font-family: "Pacifico", "Brush Script MT", cursive;
  font-size: 1.75rem;
  line-height: 1;
}
.brand span { padding-bottom: 4px; }
.brand svg { display: block; transition: transform .2s; }
.brand:hover svg { transform: rotate(-6deg) scale(1.05); }
.lang-switch { display: flex; background: var(--chip-d); border: 1px solid var(--line-d); border-radius: 999px; padding: 3px; }
.lang-switch a {
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted-d);
  font-size: .9rem;
  font-weight: 600;
}
.lang-switch a.on { background: var(--accent-bg); color: var(--accent-on); }

/* landing */
.home { text-align: center; padding: 36px 0 20px; }
.home h1 { margin: 0; font-family: "Jost", "Segoe UI", sans-serif; font-weight: 300; font-size: clamp(2.2rem, 7vw, 3.2rem); letter-spacing: 0; line-height: 1.12; }
.tagline {
  margin: 6px 0 14px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.45rem, 4.6vw, 1.9rem);
  color: var(--yellow);
}
.lede { margin: 0 auto 28px; color: var(--muted-d); max-width: 30em; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 30px 14px 26px;
  border-radius: var(--radius);
  background: var(--chip-d);
  border: 2px solid var(--line-d);
  text-decoration: none;
  color: var(--ink-d);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.pick-tile:hover, .pick-tile:focus-visible { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0, 0, 0, .3); outline: none; }
.pick-tile.es:hover, .pick-tile.es:focus-visible { border-color: var(--es); }
.pick-tile.pt:hover, .pick-tile.pt:focus-visible { border-color: var(--pt); }
.pick-hello { font-family: "Pacifico", "Brush Script MT", cursive; font-size: clamp(2rem, 7.5vw, 2.6rem); line-height: 1.5; }
.pick-tile.es .pick-hello { color: var(--es); }
.pick-tile.pt .pick-hello { color: var(--pt); }
.pick-name { font-weight: 700; font-size: 1.1rem; }
.pick-sub { color: var(--muted-d); font-size: .85rem; }
.home-note { color: var(--muted-d); font-size: .92rem; margin: 26px auto 0; max-width: 32em; }

/* level filter */
.levels { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 14px 0 16px; }
.levels button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-d);
  background: var(--chip-d);
  color: var(--ink-d);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: .9rem;
}
.levels button i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.levels .lv-e i { background: var(--easy); }
.levels .lv-m i { background: var(--medium); }
.levels .lv-h i { background: var(--hard); }
.levels .lv-f i { background: #ff7ab8; }
.levels .n { color: var(--muted-d); font-size: .8rem; }
.levels button.on { background: var(--ink-d); border-color: var(--ink-d); color: var(--ink); }
.levels button.on .n { color: var(--muted); }
.levels button.lv-e.on .n, .levels button.lv-m.on .n, .levels button.lv-h.on .n, .levels button.lv-f.on .n { color: rgba(255, 255, 255, .75); }
.levels button.lv-e.on { background: var(--easy); border-color: var(--easy); color: #fff; }
.levels button.lv-m.on { background: var(--medium); border-color: var(--medium); color: #fff; }
.levels button.lv-h.on { background: var(--hard); border-color: var(--hard); color: #fff; }
.levels button.lv-f.on { background: #e0559a; border-color: #e0559a; color: #fff; }

/* card */
.stage { perspective: 1400px; }
.card {
  --lv: var(--easy);
  --lv-soft: var(--easy-soft);
  position: relative;
  height: min(62vh, 400px);
  min-height: 320px;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.card.lv-m { --lv: var(--medium); --lv-soft: var(--medium-soft); }
.card.lv-h { --lv: var(--hard); --lv-soft: var(--hard-soft); }
.card-inner { position: absolute; inset: 0; transition: transform .45s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.card.flipped .card-inner { transform: rotateY(180deg); }
.card.instant .card-inner { transition: none; }
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid var(--lv);
  color: var(--ink);
  font-family: "Jost", "Segoe UI", sans-serif;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .35), inset 0 6px 0 var(--lv);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 34px 22px 24px;
  overflow: auto;
}
.card:focus-visible .face { box-shadow: 0 0 0 4px var(--lv-soft), inset 0 6px 0 var(--lv); }
.front { background: linear-gradient(180deg, var(--lv-soft), var(--panel) 55%); }
.back { transform: rotateY(180deg); justify-content: flex-start; padding-top: 44px; }
.pill {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--lv);
  background: var(--lv-soft);
  border-radius: 999px;
  padding: 3px 10px;
}
.word { font-size: clamp(2.2rem, 9vw, 3.5rem); font-weight: 400; letter-spacing: 0; line-height: 1.1; overflow-wrap: anywhere; }
.art { color: var(--muted); font-weight: 300; font-size: .55em; margin-right: .3em; }
.art:empty { display: none; }
.say { margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.pron { color: var(--accent-card); font-size: 1.1rem; font-weight: 400; letter-spacing: .06em; }
.speak {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.speak.off { display: none; }
.hint { position: absolute; bottom: 16px; font-size: .8rem; color: var(--muted); }

.mini { color: var(--muted); font-size: .95rem; }
.mini .w { font-weight: 500; color: var(--ink); }
.mini .art { font-size: .95em; margin-right: .2em; }
.mini .pron { font-size: .85rem; }
.meaning { font-size: clamp(1.8rem, 7vw, 2.6rem); font-weight: 300; margin: 10px 0 18px; line-height: 1.15; }
.other { width: 100%; border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rel { font-size: .76rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; }
.rel.same, .rel.accent { background: var(--easy-soft); color: var(--easy); }
.rel.similar { background: var(--medium-soft); color: var(--medium); }
.rel.different { background: #efeae2; color: var(--muted); }
.other-word { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 10px; font-size: 1.45rem; font-weight: 400; }
.other-word .art { font-size: .75em; margin-right: 0; }
.other-word .pron { font-size: .9rem; font-weight: 400; }
.other-word .speak { width: 32px; height: 32px; font-size: .85rem; }
.other-word .pron { color: var(--other-card); }
.gender { margin: 0; font-size: .88rem; color: var(--muted); }
.gender:empty, .note:empty { display: none; }
.note {
  margin: 14px 0 0;
  font-size: .9rem;
  background: var(--hard-soft);
  color: #8a2a1f;
  border-radius: 10px;
  padding: 8px 12px;
  max-width: 28em;
}

/* progress and controls */
.progress { display: flex; align-items: center; gap: 12px; margin: 16px 2px 0; }
.bar { flex: 1; height: 4px; background: var(--line-d); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.counter { font-size: .85rem; color: var(--muted-d); font-variant-numeric: tabular-nums; white-space: nowrap; }
.controls { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.nav-btn, .flip-btn {
  border-radius: 12px;
  padding: 9px 18px;
  font-size: .9rem;
  font-weight: 600;
  border: 1px solid var(--line-d);
  background: var(--chip-d);
  color: var(--ink-d);
}
@media (hover: hover) { .nav-btn:hover { border-color: var(--accent); color: var(--accent); } .speak:hover { border-color: var(--accent); } }
.flip-btn { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-on); padding: 9px 26px; }
.flip-btn:hover { filter: brightness(1.08); }
.tools { display: flex; align-items: center; justify-content: space-between; margin: 12px 2px 0; gap: 10px; }
.tool { border: 1px solid var(--line-d); background: transparent; color: var(--muted-d); border-radius: 999px; padding: 5px 13px; font-size: .85rem; }
.tool[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-on); }
.keys { font-size: .78rem; color: var(--muted-d); }
@media (hover: none) { .keys { display: none; } }

.credits { text-align: center; color: var(--muted-d); font-size: .8rem; padding: 34px 20px 70px; max-width: 640px; margin: 0 auto; }

@media (max-width: 420px) {
  .pick { grid-template-columns: 1fr; }
  .pick-tile { padding: 22px 14px; }
  .nav-btn { font-size: .86rem; padding: 9px 14px; }
  .levels { gap: 4px; flex-wrap: nowrap; }
  .levels button { padding: 5px 8px; font-size: .8rem; gap: 4px; }
  .levels button i { width: 7px; height: 7px; }
  .levels .n { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card-inner, .pick-tile, .bar span { transition: none; }
}
