/* Turkish Tutor — visual identity drawn from Iznik ceramic tilework:
   cobalt + turquoise + coral on warm paper. */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Inter:wght@400;500;600&family=Space+Mono:wght@400;700&display=swap');

:root {
  --paper:      #FBF8F2;
  --paper-2:    #F3EDE0;
  --ink:        #16223A;
  --ink-soft:   #5A6276;
  --cobalt:     #1E3A8A;
  --cobalt-2:   #2A4FB8;
  --turquoise:  #128B8B;
  --turquoise-2:#16A6A6;
  --coral:      #D6492F;
  --gold:       #C9962E;
  --line:       #E2D9C7;
  --good:       #1F8A4C;
  --warn:       #C9962E;
  --bad:        #C0392B;

  --radius: 14px;
  --shadow: 0 1px 0 var(--line), 0 10px 30px -18px rgba(22,34,58,.45);

  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(22,166,166,.10), transparent 40%),
    radial-gradient(circle at 110% 0%, rgba(30,58,138,.08), transparent 45%),
    var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--turquoise-2);
  outline-offset: 2px;
}

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 288px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--cobalt);
  color: #EAF1FF;
  padding: 26px 20px 40px;
  position: sticky; top: 0; align-self: start; height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand .tile { width: 34px; height: 34px; flex: none; }
.brand h1 {
  font-family: var(--display); font-weight: 800; font-size: 1.28rem;
  letter-spacing: -.01em; margin: 0; line-height: 1;
}
.brand .sub { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #9DB4E8; }

.lesson-picker { margin: 22px 0 18px; }
.lesson-picker label { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: #9DB4E8; }
.lesson-picker select {
  width: 100%; margin-top: 6px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid #34509E; background: #16306F; color: #EAF1FF;
  font-family: inherit; font-size: .9rem;
}

.section-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.section-list button {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: #D6E1F8; font-size: .9rem; transition: background .15s, color .15s;
}
.section-list button:hover { background: #16306F; }
.section-list button[aria-current="true"] {
  background: var(--paper); color: var(--ink); font-weight: 600;
}
.section-list .num {
  font-family: var(--mono); font-size: .72rem; font-weight: 700;
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  border-radius: 7px; background: var(--turquoise); color: #fff;
}
.section-list button[aria-current="true"] .num { background: var(--coral); }

/* ---------- Main ---------- */
.main { padding: 40px clamp(20px, 5vw, 64px) 80px; max-width: 940px; }
.eyebrow {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--turquoise);
}
.main h2 {
  font-family: var(--display); font-weight: 800; font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  letter-spacing: -.02em; margin: 6px 0 4px; line-height: 1.05;
}
.lede { color: var(--ink-soft); max-width: 60ch; margin: 0 0 28px; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--cobalt); background: var(--cobalt); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .92rem;
  display: inline-flex; align-items: center; gap: 8px; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--cobalt); }
.btn.coral { background: var(--coral); border-color: var(--coral); }
.btn.turq { background: var(--turquoise); border-color: var(--turquoise); }
.btn.small { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; color: var(--cobalt);
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--paper-2); }

/* ---------- Dialog ---------- */
.turn { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.turn:last-child { border-bottom: none; }
.turn .who {
  font-family: var(--mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
  color: #fff; background: var(--turquoise); padding: 3px 8px; border-radius: 6px; height: fit-content;
}
.turn:nth-child(even) .who { background: var(--coral); }
.turn .lines { flex: 1; }
.turn .tr { font-size: 1.12rem; font-weight: 600; }
.turn .en { color: var(--ink-soft); font-size: .94rem; }

/* ---------- Tutorial ---------- */
.vocab-table { width: 100%; border-collapse: collapse; }
.vocab-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vocab-table .tr-cell { font-weight: 700; color: var(--cobalt); white-space: nowrap; }
.vocab-table .en-cell { width: 26%; color: var(--ink); }
.vocab-table .note-cell { color: var(--ink-soft); font-size: .9rem; }
.grammar-note h4 { font-family: var(--display); margin: 0 0 4px; font-size: 1.05rem; }
.grammar-note { padding: 14px 0; border-bottom: 1px solid var(--line); }
.grammar-note:last-child { border-bottom: none; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md ul { margin: 0 0 10px; padding-left: 20px; }
.md li { margin: 3px 0; }
.md code { font-family: var(--mono); background: var(--paper-2); padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.md-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: .9rem; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.md-table th { background: var(--paper-2); font-family: var(--display); font-weight: 700; }
.md-table strong { color: var(--cobalt); }

/* ---------- Turkish keyboard legend ---------- */
.kbd-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 9px 16px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px;
}
.kbd-title {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft);
}
.kbd-pair { display: inline-flex; align-items: center; gap: 5px; font-size: .98rem; }
.kbd-arrow { color: var(--ink-soft); }
.kbd-letter { font-weight: 700; color: var(--cobalt); }
.kbd-legend kbd {
  font-family: var(--mono); font-size: .82rem; background: #fff;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 2px 7px; min-width: 20px; text-align: center;
}
.kbd-note { font-size: .8rem; color: var(--ink-soft); }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(circle at 12% -10%, rgba(22,166,166,.12), transparent 42%),
    radial-gradient(circle at 110% 0%, rgba(30,58,138,.10), transparent 46%),
    var(--paper);
}
.login-card {
  width: 100%; max-width: 340px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 26px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-mark { font-family: var(--display); font-weight: 800; font-size: 1.7rem; color: var(--cobalt); letter-spacing: -.02em; }
.login-sub { margin: -6px 0 6px; color: var(--ink-soft); }
.login-card .answer-input { text-align: left; font-size: 1rem; }

/* ---------- Drill cards ---------- */
.prompt-big {
  font-family: var(--display); font-weight: 700; font-size: clamp(1.6rem, 4vw, 2.4rem);
  letter-spacing: -.01em; text-align: center; margin: 6px 0 4px;
}
.prompt-sub { text-align: center; color: var(--ink-soft); margin-bottom: 18px; }
.center-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.progress { font-family: var(--mono); font-size: .78rem; color: var(--ink-soft); letter-spacing: .06em; }

.answer-input {
  width: 100%; padding: 14px 16px; font-size: 1.2rem; font-family: var(--body);
  border: 2px solid var(--line); border-radius: 12px; text-align: center; margin: 8px 0;
}
.answer-input:focus { border-color: var(--turquoise); outline: none; }
.answer-input.correct { border-color: var(--good); background: #F2FBF5; }
.answer-input.wrong { border-color: var(--bad); background: #FDF3F2; }

.feedback { text-align: center; min-height: 1.4em; font-weight: 600; margin: 6px 0; }
.feedback.good { color: var(--good); }
.feedback.warn { color: var(--warn); }
.feedback.bad  { color: var(--bad); }
.reveal { text-align: center; color: var(--ink-soft); }
.reveal b { color: var(--cobalt); }

/* ---------- Matching ---------- */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.match-col { display: grid; gap: 10px; }
.match-col h4 { margin: 0 0 2px; font-family: var(--display); font-size: .9rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .1em; }
.chip {
  text-align: left; padding: 12px 14px; border-radius: 10px; border: 2px solid var(--line);
  background: #fff; font-size: 1rem; font-weight: 500; transition: border-color .12s, background .12s;
}
.chip:hover { border-color: var(--cobalt-2); }
.chip.selected { border-color: var(--cobalt); background: #EEF2FD; }
.chip.matched { border-color: var(--good); background: #F2FBF5; color: var(--good); cursor: default; pointer-events: none; }
.chip.tr { font-weight: 700; color: var(--cobalt); }
.chip.matched.tr { color: var(--good); }
.chip[draggable="true"] { cursor: grab; }
.chip[draggable="true"]:active { cursor: grabbing; }
.chip.dragging { opacity: .45; }
.chip.drop { cursor: default; }
.chip.drop-hover { border-color: var(--cobalt); background: #EEF2FD; border-style: dashed; }
.chip.wrong { border-color: var(--bad); background: #FDF3F2; }
.chip.matched { pointer-events: none; }

/* ---------- Conversation ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; min-height: 120px; }
.bubble { max-width: 78%; padding: 11px 15px; border-radius: 16px; font-size: 1.02rem; }
.bubble.assistant { background: var(--paper-2); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble.user { background: var(--cobalt); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.bubble .who-sm { font-family: var(--mono); font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; opacity: .55; margin-bottom: 3px; }
.turn-prompt { border: 2px dashed var(--line); border-radius: 12px; padding: 14px 16px; }
.prompt-label { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.prompt-en { font-family: var(--display); font-weight: 700; font-size: 1.3rem; color: var(--ink); margin: 4px 0 6px; }

.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; display: inline-block; }
.recording .rec-dot { background: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.score-pill {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono);
  font-weight: 700; padding: 6px 12px; border-radius: 999px; color: #fff; font-size: .85rem;
}
.score-pill.good { background: var(--good); }
.score-pill.warn { background: var(--warn); }
.score-pill.bad  { background: var(--bad); }
.heard { font-family: var(--mono); font-size: .85rem; color: var(--ink-soft); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: .9rem; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); z-index: 50; max-width: 90vw;
}

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

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .section-list { grid-template-columns: repeat(2, 1fr); }
  .match-grid { gap: 16px; }
}
