/* ===========================================================
   che, ¿estudiamos? — porteño paper
   Palette: warm cream paper · Argentine celeste · Sol de Mayo gold
   Type: Fraunces (display, español) · Manrope (UI + русский/Cyrillic)
   =========================================================== */

:root {
  --paper:      #f4eede;
  --paper-2:    #efe7d3;
  --card:       #fbf8f0;
  --ink:        #221f1a;
  --ink-soft:   #6a6457;
  --ink-faint:  #9a9384;
  --line:       #e3d9c2;

  --celeste:    #6fb1da;
  --celeste-dp: #2f78a8;
  --celeste-ink:#1f567a;
  --sol:        #edab3a;
  --sol-dp:     #c7842a;
  --jade:       #2f8a6c;
  --terra:      #c8553d;
  --plum:       #7a5a9e;

  --cat-sust: var(--celeste-dp);
  --cat-glag: var(--jade);
  --cat-pril: var(--sol-dp);
  --cat-sluzh:var(--plum);
  --cat-arg:  var(--terra);

  --shadow-sm: 0 1px 2px rgba(40,32,18,.06), 0 3px 8px rgba(40,32,18,.06);
  --shadow-md: 0 4px 14px rgba(40,32,18,.10), 0 18px 40px -18px rgba(40,32,18,.30);
  --shadow-lg: 0 10px 30px rgba(40,32,18,.12), 0 40px 80px -30px rgba(47,120,168,.35);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 26px;
  --maxw: 880px;

  --font-disp: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Manrope", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(120% 90% at 88% -10%, rgba(111,177,218,.22), transparent 55%),
    radial-gradient(90% 70% at 8% 108%, rgba(237,171,58,.14), transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 760px) { body { padding-bottom: 40px; } }

/* paper grain + ambient glow ----------------------------------- */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/></svg>");
}
.glow { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* topbar ------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px clamp(16px, 4vw, 40px);
  background: linear-gradient(var(--paper) 62%, rgba(244,238,222,0));
  backdrop-filter: saturate(120%);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.brand-text { font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-text em { font-style: italic; font-family: var(--font-disp); font-weight: 600; color: var(--celeste-ink); }
.brand-sun {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 45%, #f6c659, var(--sol) 58%, var(--sol-dp));
  box-shadow: 0 0 0 3px rgba(237,171,58,.18), 0 0 18px rgba(237,171,58,.5);
  position: relative;
}
.brand-sun::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent 0 8%, rgba(237,171,58,.55) 8% 12%, transparent 12% 25%,
    rgba(237,171,58,.55) 25% 29%, transparent 29% 50%, rgba(237,171,58,.55) 50% 54%,
    transparent 54% 75%, rgba(237,171,58,.55) 75% 79%, transparent 79%);
  -webkit-mask: radial-gradient(circle, transparent 56%, #000 57%);
          mask: radial-gradient(circle, transparent 56%, #000 57%);
  animation: spin 26s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.nav-desktop { display: none; gap: 4px; }
@media (min-width: 760px) {
  .nav-desktop { display: flex; }
  .nav-desktop a {
    text-decoration: none; color: var(--ink-soft); font-weight: 600; font-size: 15px;
    padding: 8px 16px; border-radius: 999px; transition: .18s;
  }
  .nav-desktop a:hover { color: var(--ink); background: rgba(255,255,255,.55); }
  .nav-desktop a.active { color: #fff; background: var(--celeste-dp); box-shadow: var(--shadow-sm); }
}

/* layout ------------------------------------------------------- */
main { position: relative; z-index: 1; }
.view { max-width: var(--maxw); margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 40px; }
.view[hidden] { display: none; }

.view-head { margin: 6px 0 18px; }
.view-head h1 {
  font-family: var(--font-disp); font-weight: 600; font-size: clamp(26px, 6vw, 40px);
  letter-spacing: -.02em; margin: 0; line-height: 1.05;
}
.view-head p { margin: 6px 0 0; color: var(--ink-soft); font-size: 15px; }

/* chips / filters --------------------------------------------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 20px; }
.chip {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card);
  color: var(--ink-soft); font-weight: 600; font-size: 13.5px; padding: 7px 14px;
  border-radius: 999px; transition: .16s; line-height: 1; white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: #cdbf9f; }
.chip[aria-pressed="true"] { color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.chip[aria-pressed="true"][data-cat="all"]  { background: var(--ink); }
.chip[aria-pressed="true"][data-cat="sust"] { background: var(--cat-sust); }
.chip[aria-pressed="true"][data-cat="glag"] { background: var(--cat-glag); }
.chip[aria-pressed="true"][data-cat="pril"] { background: var(--cat-pril); }
.chip[aria-pressed="true"][data-cat="sluzh"]{ background: var(--cat-sluzh); }
.chip[aria-pressed="true"][data-cat="arg"]  { background: var(--cat-arg); }
.toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.toggle input { accent-color: var(--celeste-dp); width: 16px; height: 16px; }

/* ===== STUDY ================================================== */
.study-wrap { display: flex; flex-direction: column; align-items: center; }
.progress {
  width: 100%; max-width: 560px; display: flex; align-items: center; gap: 12px;
  margin: 4px 0 18px; color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.progress .bar { flex: 1; height: 7px; border-radius: 999px; background: var(--paper-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.progress .bar i { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--celeste), var(--celeste-dp)); transition: width .35s ease; }

.flashcard {
  width: 100%; max-width: 560px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); padding: 26px 24px 24px;
  position: relative; overflow: hidden;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.flashcard::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: var(--accent, var(--celeste-dp));
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.fc-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; min-height: 24px; }
.badge {
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; color: #fff; background: var(--accent, var(--celeste-dp));
}
.badge.vos { background: linear-gradient(180deg, var(--sol), var(--sol-dp)); }
.badge.pair { background: var(--plum); }
.badge.ghost { background: transparent; color: var(--ink-faint); border: 1px solid var(--line); }

.fc-img {
  display: block; width: 132px; height: 132px; margin: 4px auto 12px;
  border-radius: var(--r-md); background: #fff; box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.fc-emoji {
  width: 132px; height: 132px; margin: 4px auto 12px; display: grid; place-items: center;
  font-size: 74px; line-height: 1; border-radius: var(--r-md);
  background: radial-gradient(circle at 50% 42%, #ffffff, #f1e9d6);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.fc-emoji .om { width: 90px; height: 90px; display: block; }
.fc-word {
  font-family: var(--font-disp); font-weight: 600; text-align: center;
  font-size: clamp(34px, 9vw, 54px); line-height: 1.04; letter-spacing: -.02em;
  color: var(--ink); margin: 2px 0 4px; word-break: break-word;
  font-optical-sizing: auto;
}
.fc-front-hint { text-align: center; color: var(--ink-faint); font-size: 13.5px; margin-top: 14px; }

.reveal { animation: fade .32s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.fc-tr { text-align: center; font-size: clamp(19px, 5vw, 24px); font-weight: 700; margin-top: 6px; }
.fc-vos {
  text-align: center; margin: 8px auto 2px; display: inline-block; left: 50%; position: relative; transform: translateX(-50%);
  font-family: var(--font-disp); font-style: italic; color: var(--celeste-ink); font-size: 18px;
}
.fc-vos-wrap { text-align: center; }
.fc-divider { height: 1px; background: var(--line); margin: 16px 0; }
.fc-ex { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.fc-ex li { padding-left: 14px; border-left: 2px solid var(--line); }
.fc-ex .es { font-family: var(--font-disp); font-size: 17px; color: var(--ink); }
.fc-ex .ru { color: var(--ink-soft); font-size: 14.5px; }
.fc-mnem {
  margin-top: 16px; background: linear-gradient(180deg, #fff8e8, #fdf2d6);
  border: 1px solid #f0dca6; border-radius: var(--r-md); padding: 13px 15px;
  font-size: 14.5px; color: #6b5520; line-height: 1.55;
}
.fc-mnem b { color: var(--sol-dp); font-weight: 800; }

.fc-actions { margin-top: 20px; }
.btn-reveal {
  width: 100%; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
  padding: 15px; border-radius: var(--r-md); border: 0; color: #fff;
  background: linear-gradient(180deg, var(--celeste), var(--celeste-dp));
  box-shadow: var(--shadow-sm); transition: transform .12s, filter .12s;
}
.btn-reveal:hover { filter: brightness(1.05); }
.btn-reveal:active { transform: translateY(1px) scale(.995); }

.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--r-md); padding: 13px 8px 11px; text-align: center; transition: .14s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.grade:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.grade .k { font-weight: 800; font-size: 18px; }
.grade .t { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.grade.g1:hover { border-color: var(--terra); } .grade.g1 .k { color: var(--terra); }
.grade.g2:hover { border-color: var(--sol-dp); } .grade.g2 .k { color: var(--sol-dp); }
.grade.g3:hover { border-color: var(--jade);  } .grade.g3 .k { color: var(--jade); }

.empty {
  text-align: center; padding: 48px 20px; max-width: 460px; margin: 20px auto;
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--r-lg);
}
.empty .big { font-family: var(--font-disp); font-size: 26px; font-style: italic; color: var(--celeste-ink); }
.empty p { color: var(--ink-soft); }

/* ===== LIST ================================================== */
.wordgrid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .wordgrid { grid-template-columns: 1fr 1fr; } }
.wordrow {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 11px 13px; cursor: pointer; transition: .14s; font: inherit;
}
.wordrow:hover { border-color: #cdbf9f; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.wordrow .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 6px; }
.wordrow .emoji { flex: none; width: 26px; height: 24px; display: grid; place-items: center; text-align: center; font-size: 20px; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.wordrow .emoji .om { width: 23px; height: 23px; display: block; }
.wordrow .es { font-family: var(--font-disp); font-size: 18px; font-weight: 600; }
.wordrow .tr { color: var(--ink-soft); font-size: 13.5px; margin-top: 1px; }
.wordrow .mid { min-width: 0; flex: 1; }
.wordrow .es, .wordrow .tr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wordrow .vos { font-size: 12px; color: var(--celeste-ink); font-style: italic; font-family: var(--font-disp); }
.count-note { color: var(--ink-faint); font-size: 13px; margin: 16px 2px 0; }

/* ===== SEARCH ================================================ */
.searchbox { position: relative; margin-bottom: 8px; }
.searchbox input {
  width: 100%; font: inherit; font-size: 17px; padding: 15px 16px 15px 46px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card);
  color: var(--ink); box-shadow: var(--shadow-sm); outline: none;
}
.searchbox input:focus { border-color: var(--celeste); box-shadow: 0 0 0 3px rgba(111,177,218,.25); }
.searchbox::before { content: "⌕"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-size: 20px; }

/* ===== STATS ================================================= */
.stat-cards { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 22px; }
@media (min-width: 560px) { .stat-cards { grid-template-columns: repeat(4, 1fr); } }
.statc { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.statc .n { font-family: var(--font-disp); font-size: 30px; font-weight: 600; line-height: 1; }
.statc .l { color: var(--ink-soft); font-size: 13px; margin-top: 6px; font-weight: 600; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px; }
.panel h2 { font-family: var(--font-disp); font-weight: 600; font-size: 19px; margin: 0 0 14px; }
.barrow { display: grid; grid-template-columns: 78px 1fr 44px; align-items: center; gap: 12px; margin-bottom: 9px; font-size: 13.5px; }
.barrow .lab { color: var(--ink-soft); font-weight: 600; }
.barrow .track { height: 12px; border-radius: 999px; background: var(--paper-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.barrow .track i { display: block; height: 100%; border-radius: 999px; transition: width .5s ease; }
.barrow .v { text-align: right; color: var(--ink-soft); font-weight: 700; }
.boxes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.box { text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 6px; }
.box .bn { font-family: var(--font-disp); font-size: 22px; font-weight: 600; }
.box .bl { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.credit { margin-top: 22px; opacity: .85; }
.credit a { color: var(--celeste-dp); text-decoration: none; }
.credit a:hover { text-decoration: underline; }
.danger { background: none; border: 1px solid var(--line); color: var(--terra); font: inherit; font-weight: 600; font-size: 13.5px; padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.danger:hover { border-color: var(--terra); background: rgba(200,85,61,.06); }

/* ===== modal (word detail) ================================== */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
@media (min-width: 560px) { .modal { align-items: center; } }
.modal-backdrop { position: absolute; inset: 0; background: rgba(34,31,26,.42); backdrop-filter: blur(2px); animation: fade .2s ease; }
.modal-card {
  position: relative; width: 100%; max-width: 480px; max-height: 86vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 22px;
  box-shadow: var(--shadow-lg); animation: sheet .3s cubic-bezier(.2,.8,.2,1) both;
}
@media (min-width: 560px) { .modal-card { border-radius: var(--r-lg); } }
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card .close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 18px; color: var(--ink-soft); }

/* mobile nav -------------------------------------------------- */
.nav-mobile {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(251,248,240,.92); backdrop-filter: blur(10px) saturate(120%);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 760px) { .nav-mobile { display: none; } }
.nav-mobile a {
  text-decoration: none; color: var(--ink-faint); font-size: 11px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; transition: color .15s;
}
.nav-mobile a .ic { font-size: 17px; line-height: 1; }
.nav-mobile a.active { color: var(--celeste-dp); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .brand-sun::after { animation: none; }
}
