/* ============================================================
   Eesti grammatika — shared styles (FB-like, light theme)
   ============================================================ */
:root {
  --fb-bg: #f0f2f5;
  --fb-card: #ffffff;
  --fb-text: #050505;
  --fb-text-secondary: #65676b;
  --fb-text-tertiary: #8a8d91;
  --fb-divider: #ced0d4;
  --fb-divider-soft: #e4e6eb;
  --fb-hover: #f2f2f2;
  --fb-chip-bg: #e4e6eb;
  --fb-chip-hover: #d8dadf;
  --fb-primary: #1877f2;
  --fb-primary-hover: #166fe5;
  --fb-primary-active: #0e5fcc;
  --fb-primary-soft: #e7f3ff;
  --fb-primary-soft-hover: #d8eaff;
  --fb-success: #31a24c;
  --fb-success-soft: #e3f1d5;
  --fb-error: #e41e3f;
  --fb-error-soft: #ffeaee;
  --fb-warning: #f7b928;
  --fb-warning-soft: #fff4d6;
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.12);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
               Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--fb-bg);
  color: var(--fb-text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 0 96px; }

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--fb-card);
  border-bottom: 1px solid var(--fb-divider);
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
header .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.flag {
  display: inline-flex; gap: 1px;
  border-radius: 3px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--fb-divider) inset;
  flex-shrink: 0;
}
.flag span { width: 14px; height: 9px; display: block; }
.flag .b { background: #0072ce; }
.flag .k { background: #11100c; }
.flag .w { background: #f5f5f0; }
h1 {
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
h1 em { color: var(--fb-primary); font-style: normal; font-weight: 700; }
.header-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--fb-chip-bg);
  color: var(--fb-text);
  border: none; cursor: pointer; text-decoration: none;
  transition: background 0.15s;
  flex-shrink: 0;
}
.header-action:hover { background: var(--fb-chip-hover); }

/* ---------- Language switch ---------- */
.lang-switch {
  display: inline-flex;
  background: var(--fb-chip-bg);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-switch button {
  background: transparent;
  border: none;
  color: var(--fb-text-secondary);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}
.lang-switch button.on {
  background: var(--fb-card);
  color: var(--fb-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ---------- Page layout ---------- */
.page { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.lang-block { display: none; }
.lang-block.on { display: block; }
.lang-block > * + * { margin-top: 12px; }

/* ---------- Hero ---------- */
.hero {
  background: var(--fb-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px 22px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute;
  right: -40px; top: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--fb-primary-soft), transparent 70%);
  pointer-events: none;
}
.hero .tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fb-primary);
  font-weight: 700;
  margin-bottom: 6px;
}
.hero .big {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--fb-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 10px;
}
.hero .lead {
  color: var(--fb-text-secondary);
  font-size: 1rem;
  font-weight: 500;
}

/* ---------- Card ---------- */
.card {
  background: var(--fb-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
}
.card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
  color: var(--fb-text);
}
.card h2::before {
  content: "";
  width: 4px; height: 20px;
  background: var(--fb-primary);
  border-radius: 2px;
  flex-shrink: 0;
}
.card h3 {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--fb-text);
}
.card h3:first-child { margin-top: 0; }
.card p { margin-bottom: 10px; }
.card p:last-child { margin-bottom: 0; }
.card ul, .card ol { margin: 6px 0 12px 24px; }
.card li { margin-bottom: 6px; }
.card strong { font-weight: 700; }
.card em {
  color: var(--fb-primary);
  font-style: normal;
  font-weight: 600;
}
.card code {
  background: var(--fb-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--fb-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Examples ---------- */
.ex-box {
  background: var(--fb-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 6px 0;
  border-left: 3px solid var(--fb-primary);
}
.ex-et { color: var(--fb-primary); font-weight: 600; }
.ex-tr { color: var(--fb-text-secondary); font-size: 0.9rem; margin-top: 3px; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-block;
  background: var(--fb-primary-soft);
  color: var(--fb-primary);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 2px 3px;
}

/* ---------- Notes ---------- */
.note {
  background: var(--fb-success-soft);
  color: #1f6e34;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.92rem;
  margin: 10px 0;
  display: flex; gap: 10px; align-items: flex-start;
}
.warn {
  background: var(--fb-warning-soft);
  color: #7a5b00;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.92rem;
  margin: 10px 0;
}
.fun {
  background: linear-gradient(135deg, #ffe7d6, #ffd4f0);
  color: #7a3a00;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.92rem;
  margin: 10px 0;
}
.fun strong { color: #5a2900; }

/* ---------- Tables ---------- */
table.grid {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.92rem;
}
table.grid th, table.grid td {
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid var(--fb-divider-soft);
  vertical-align: top;
}
table.grid th {
  color: var(--fb-text-secondary);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--fb-bg);
}
table.grid td:first-child { color: var(--fb-primary); font-weight: 600; }
table.grid tr:hover td { background: rgba(231, 243, 255, 0.4); }

/* Compact comparison table (3+ columns of forms) */
table.forms {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.92rem;
  text-align: center;
}
table.forms th, table.forms td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--fb-divider-soft);
}
table.forms th {
  color: var(--fb-text-secondary);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--fb-bg);
}

/* ---------- Highlight boxes ---------- */
.highlight {
  background: var(--fb-primary-soft);
  border-left: 4px solid var(--fb-primary);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 12px 0;
}
.highlight h3 { color: var(--fb-primary); margin-top: 0 !important; }
.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--fb-primary-active);
  background: var(--fb-card);
  padding: 8px 12px;
  border-radius: 4px;
  display: inline-block;
  margin: 4px 0;
}

/* ---------- Story / opening hook ---------- */
.story-open {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--fb-text-secondary);
  padding: 4px 16px;
  border-left: 3px solid var(--fb-divider);
  margin: 4px 0 12px;
}

/* ---------- Exercises ---------- */
.exercises-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--fb-primary);
  margin: 24px 0 4px;
  text-align: center;
  letter-spacing: -0.01em;
}
.exercises-sub {
  text-align: center;
  color: var(--fb-text-secondary);
  font-size: 0.92rem;
  margin-bottom: 16px;
}
.exercise {
  background: var(--fb-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  margin-bottom: 12px;
}
.exercise .ex-q {
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--fb-text);
}
.exercise .ex-q small {
  display: block;
  font-weight: 500;
  color: var(--fb-text-secondary);
  margin-top: 3px;
  font-size: 0.86rem;
}
.exercise input[type="text"] {
  width: 100%; max-width: 320px;
  padding: 9px 12px;
  border: 1.5px solid var(--fb-divider);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.96rem;
  color: var(--fb-text);
  background: var(--fb-card);
  transition: border-color 0.15s, background 0.15s;
}
.exercise input[type="text"]:focus {
  outline: none;
  border-color: var(--fb-primary);
}
.exercise input[type="text"].correct {
  border-color: var(--fb-success);
  background: var(--fb-success-soft);
  color: #1f6e34;
}
.exercise input[type="text"].wrong {
  border-color: var(--fb-error);
  background: var(--fb-error-soft);
  color: #a01a30;
}
.exercise .choice {
  display: block;
  padding: 9px 12px;
  margin: 6px 0;
  background: var(--fb-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.exercise .choice:hover { background: var(--fb-hover); }
.exercise .choice input { margin-right: 10px; vertical-align: middle; }
.exercise .choice.correct-answer {
  background: var(--fb-success-soft);
  color: #1f6e34;
  font-weight: 600;
}
.exercise .choice.wrong-answer {
  background: var(--fb-error-soft);
  color: #a01a30;
  font-weight: 600;
}
.exercise .explain {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--fb-primary-soft);
  color: var(--fb-primary-active);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border-left: 3px solid var(--fb-primary);
}
.exercise.checked .explain { display: block; }
.exercise.checked.correct {
  box-shadow: 0 0 0 2px var(--fb-success-soft), var(--shadow-card);
}
.exercise.checked.incorrect {
  box-shadow: 0 0 0 2px var(--fb-error-soft), var(--shadow-card);
}
.ex-check {
  background: var(--fb-primary);
  color: #fff;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.15s;
}
.ex-check:hover { background: var(--fb-primary-hover); }
.ex-check:disabled { background: var(--fb-divider); cursor: default; }

.check-all-bar {
  background: var(--fb-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  margin-top: 12px;
  text-align: center;
}
.check-all-bar .big-btn {
  background: var(--fb-primary);
  color: #fff;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.check-all-bar .big-btn:hover { background: var(--fb-primary-hover); }
.score-box {
  margin-top: 12px;
  display: none;
  font-weight: 600;
  color: var(--fb-text);
}
.score-box.shown { display: block; }
.score-box .score-num {
  color: var(--fb-primary);
  font-size: 1.4rem;
  font-weight: 800;
}
.score-box.perfect .score-num { color: var(--fb-success); }

/* ---------- Footer nav between pages ---------- */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 10px;
  margin-top: 16px;
}
.page-nav a {
  flex: 1;
  background: var(--fb-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  display: flex; flex-direction: column;
  gap: 4px;
  transition: transform 0.12s, box-shadow 0.15s;
}
.page-nav a:hover { transform: translateY(-1px); box-shadow: var(--shadow-elevated); }
.page-nav a.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.page-nav .pn-dir {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fb-text-tertiary);
  font-weight: 700;
}
.page-nav .pn-title {
  color: var(--fb-primary);
  font-weight: 700;
  font-size: 0.95rem;
}
.page-nav a.next { text-align: right; align-items: flex-end; }

/* ---------- Hub page (grammar index) ---------- */
.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fb-text-secondary);
  font-weight: 700;
  margin: 18px 4px 8px;
}
.section-title:first-child { margin-top: 6px; }
.topic-row {
  background: var(--fb-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}
.topic-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-elevated);
  background: #fafbfc;
}
.topic-row.disabled {
  opacity: 0.55;
  pointer-events: none;
}
.topic-num {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fb-primary-soft);
  color: var(--fb-primary);
  font-weight: 800;
  border-radius: 8px;
  font-size: 0.95rem;
}
.topic-row.disabled .topic-num {
  background: var(--fb-chip-bg);
  color: var(--fb-text-tertiary);
}
.topic-info { flex: 1; min-width: 0; }
.topic-name {
  font-weight: 700;
  color: var(--fb-primary);
  font-size: 0.98rem;
  margin-bottom: 2px;
}
.topic-row.disabled .topic-name { color: var(--fb-text-secondary); }
.topic-hint {
  font-size: 0.84rem;
  color: var(--fb-text-secondary);
}
.topic-status {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.topic-status.ready { background: var(--fb-success-soft); color: var(--fb-success); }
.topic-status.soon { background: var(--fb-chip-bg); color: var(--fb-text-tertiary); }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .hero .big { font-size: 1.65rem; }
  h1 { font-size: 0.95rem; }
  .card { padding: 16px 16px; }
  .hero { padding: 20px 18px; }
  table.grid, table.forms { font-size: 0.84rem; }
  table.grid th, table.grid td, table.forms th, table.forms td { padding: 7px 6px; }
  .topic-name { font-size: 0.92rem; }
  .topic-hint { font-size: 0.78rem; }
}
