/* ==========================================================================
   TaleToday · Temel stiller
   Kimlik: okul defteri. Çizgili kâğıt, kırmızı kenar çizgisi, tükenmez kalem
   mavisi, fosforlu kalem sarısı ve öğretmenin kırmızı kalemi.
   ========================================================================== */

@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/Lexend-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, 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: 'Lexend';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/Lexend-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Shantell Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/ShantellSans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, 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: 'Shantell Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/ShantellSans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  /* Kâğıt ve yüzeyler */
  --paper: #fdfdfb;
  --surface: #ffffff;
  --canvas: #f2f5f9;
  --desk: #e4e9f0;
  --line: #e3e8ef;
  --line-strong: #cdd5e1;

  /* Defter */
  --rule: #d9e6f8;
  --margin: #ec8a8a;

  /* Tükenmez kalem mavisi (ana renk) — sıralı mavi rampadan */
  --ink: #1c5cab;
  --ink-deep: #104281;
  --ink-soft: #cde2fb;
  --ink-wash: #eef4fc;

  /* Öğretmenin kalemi ve fosforlu kalem */
  --pen: #d33a3a;
  --marker: #ffe45c;

  /* Metin */
  --text: #1b2230;
  --text-2: #4a5365;
  --text-3: #737d91;

  /* Durum renkleri (yalnızca durum için; her zaman ikon + etiketle) */
  --good: #0ca30c;
  --good-text: #0b6b17;
  --good-wash: #e8f6ea;
  --warn: #fab219;
  --warn-text: #8a5700;
  --warn-wash: #fff5dd;
  --bad: #d03b3b;
  --bad-text: #b3262b;
  --bad-wash: #fdecec;

  /* Ölçüler */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 56, .05), 0 1px 3px rgba(20, 32, 56, .06);
  --shadow: 0 12px 32px -14px rgba(20, 32, 56, .25), 0 2px 6px rgba(20, 32, 56, .05);
  --shadow-lg: 0 28px 64px -24px rgba(20, 32, 56, .4);

  --font-ui: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-hand: 'Shantell Sans', 'Segoe Print', 'Comic Sans MS', cursive;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Temel ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, canvas, video { display: block; max-width: 100%; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--ink-deep); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-size: .9em; background: var(--ink-wash); padding: .1em .35em; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
:focus-visible { outline: 3px solid rgba(28, 92, 171, .45); outline-offset: 2px; }
::selection { background: var(--marker); color: var(--text); }

.icon { width: 1.15em; height: 1.15em; flex: none; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 300; background: var(--text); color: #fff; padding: 10px 14px; border-radius: 10px; }
.skip-link:focus { top: 12px; color: #fff; }
.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--text-3); }
.small { font-size: .86em; }
.hand { font-family: var(--font-hand); }
.nowrap { white-space: nowrap; }
.inline-form { display: inline; margin: 0; }
[hidden] { display: none !important; }

/* ---------- Marka ---------- */
.brand {
  display: inline-flex; align-items: center;
  font-family: var(--font-hand); font-weight: 700; font-size: 1.38rem; letter-spacing: -.01em;
  color: var(--text); text-decoration: none !important; line-height: 1;
}
.brand:hover { color: var(--text); }
.brand-hl { position: relative; z-index: 0; color: var(--ink); }
.brand-hl::after {
  content: ""; position: absolute; z-index: -1; left: -.06em; right: -.1em; bottom: .02em; height: .45em;
  background: var(--marker); border-radius: 3px 7px 4px 8px; transform: rotate(-1.6deg);
}

/* Fosforlu kalemle altı çizilmiş kelime */
.hl { position: relative; z-index: 0; white-space: nowrap; }
.hl::after {
  content: ""; position: absolute; z-index: -1; left: -.1em; right: -.12em; bottom: .06em; height: .48em;
  background: var(--marker); border-radius: .2em .45em .3em .5em; transform: rotate(-1.2deg);
}

/* Çizgili defter kâğıdı */
.notebook {
  --rule-gap: 32px;
  --margin-x: 56px;
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent calc(var(--margin-x) - 1px), var(--margin) calc(var(--margin-x) - 1px), var(--margin) calc(var(--margin-x) + 1px), transparent calc(var(--margin-x) + 1px)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--rule-gap) - 1px), var(--rule) calc(var(--rule-gap) - 1px), var(--rule) var(--rule-gap));
}
@media (max-width: 640px) {
  .notebook { --margin-x: 18px; --rule-gap: 28px; }
}

/* ---------- Butonlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 42px; padding: .55em 1.1em; border-radius: 12px; border: 1px solid transparent;
  font-weight: 500; font-size: .95rem; line-height: 1.2; cursor: pointer; white-space: nowrap;
  text-decoration: none !important; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, color .15s, transform .12s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 1.1em; height: 1.1em; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 2px 0 var(--ink-deep); }
.btn-primary:hover { background: var(--ink-deep); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--ink-wash); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--bad-text); border-color: #efc5c5; }
.btn-danger:hover { background: var(--bad-wash); color: var(--bad-text); border-color: var(--bad); }
.btn-approve { background: var(--good-text); color: #fff; }
.btn-approve:hover { background: #07511a; color: #fff; }
.btn-sm { min-height: 34px; padding: .35em .8em; font-size: .85rem; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: .7em 1.5em; font-size: 1.04rem; border-radius: 14px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--ink-wash); color: var(--ink); }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Formlar ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; align-content: start; }
.label { font-size: .86rem; font-weight: 500; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: .55em .8em; font-size: 1rem;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: #9aa3b4; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(28, 92, 171, .15); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 2.3em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a5365' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7em center; background-size: 16px;
}
.input-sm { min-height: 38px; font-size: .9rem; padding: .4em .7em; }
.help { font-size: .8rem; color: var(--text-3); }
.error-text { font-size: .82rem; color: var(--bad-text); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--bad); }
.check { display: flex; gap: .65em; align-items: flex-start; cursor: pointer; font-size: .94rem; }
.check input { margin: .2em 0 0; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--ink); flex: none; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0; display: grid; gap: 16px; }
.fieldset legend { padding: 0 6px; font-weight: 600; font-size: .92rem; }
.input-group { position: relative; }
.input-group .input { padding-right: 46px; }
.input-group .icon-btn { position: absolute; right: 2px; top: 2px; }

/* ---------- Uyarılar ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 14px;
  border-radius: 12px; border: 1px solid; font-size: .92rem;
}
.alert > .icon { margin-top: 2px; }
.alert > span { flex: 1; }
.alert-success { background: var(--good-wash); border-color: #bfe3c4; color: var(--good-text); }
.alert-error { background: var(--bad-wash); border-color: #f3c6c6; color: var(--bad-text); }
.alert-info { background: var(--ink-wash); border-color: var(--ink-soft); color: var(--ink-deep); }
.alert-warn { background: var(--warn-wash); border-color: #f4d995; color: var(--warn-text); }
.alert-close { border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; padding: 0; line-height: 0; }
.alert-close:hover { opacity: 1; }

/* ---------- Rozetler ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35em; padding: .22em .62em;
  border-radius: 999px; font-size: .76rem; font-weight: 500; line-height: 1.35; white-space: nowrap;
}
.badge .icon { width: .95em; height: .95em; }
.badge-good { background: var(--good-wash); color: var(--good-text); }
.badge-warn { background: var(--warn-wash); color: var(--warn-text); }
.badge-bad { background: var(--bad-wash); color: var(--bad-text); }
.badge-muted { background: #eef1f5; color: var(--text-2); }
.badge-ink { background: var(--ink-wash); color: var(--ink); }
.level-tag {
  display: inline-block; padding: .05em .5em; border: 1.5px solid currentColor; border-radius: 7px;
  font-family: var(--font-hand); font-weight: 700; font-size: .78rem; color: var(--ink); line-height: 1.35;
}

/* Kelime listesi türü: fosforlu kalemle işaretlenmiş etiket */
.word-kind {
  display: inline-block; padding: .12em .55em; border-radius: 4px 9px 5px 8px; font-size: .74rem; font-weight: 600;
  line-height: 1.4; white-space: nowrap; background: var(--ink-soft); color: var(--ink-deep);
}
.word-kind.is-attention { background: #ffd9b0; color: #7a3d00; }
.word-kind.is-memorize { background: var(--marker); color: #4d4000; }

/* ---------- Avatar, ilerleme ---------- */
.avatar {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%;
  background: var(--ink-wash); color: var(--ink); font-weight: 600; font-size: .82rem; letter-spacing: .02em;
}
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar-lg { width: 60px; height: 60px; font-size: 1.1rem; }
.progress { display: block; height: 6px; border-radius: 99px; background: var(--ink-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ink); border-radius: inherit; }

/* ---------- Kartlar, tablolar ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-sub { font-size: .82rem; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 8px 0 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-weight: 500; color: var(--text-3); font-size: .76rem; letter-spacing: .01em;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn, .table .actions form + .btn, .table .actions .btn + form { margin-left: 4px; }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.table td.cell-main { min-width: 190px; }
.cell-user strong { display: block; font-weight: 500; color: var(--text); }
.cell-user small { display: block; color: var(--text-3); font-size: .8rem; }
a.cell-user:hover { text-decoration: none; }
a.cell-user:hover strong { color: var(--ink); }

/* ---------- Boş durum, istatistik ---------- */
.empty { text-align: center; padding: 36px 20px; }
.empty-title { font-family: var(--font-hand); font-size: 1.25rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-text { color: var(--text-3); max-width: 48ch; margin: 0 auto 14px; font-size: .92rem; }
.empty-action { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

.stat {
  display: grid; gap: 2px; align-content: start; padding: 16px 18px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: inherit; text-decoration: none !important;
  transition: border-color .15s, box-shadow .15s;
}
.stat-label { font-size: .8rem; color: var(--text-3); }
.stat-value { font-size: 1.65rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; color: var(--text); }
.stat-value small { font-size: .55em; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.stat-sub { font-size: .8rem; color: var(--text-2); }
.stat-link:hover { border-color: #b9cdea; box-shadow: var(--shadow-sm); }

/* ---------- Öğretmen kalemi: daire içine alınmış not ---------- */
.pen-mark { position: relative; display: inline-grid; place-items: center; width: 150px; height: 96px; color: var(--pen); flex: none; }
.pen-mark svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pen-mark path { fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.pen-mark-text { position: relative; font-family: var(--font-hand); font-weight: 700; font-size: 2rem; line-height: 1; transform: rotate(-4deg); white-space: nowrap; }
.pen-mark.is-sm { width: 76px; height: 48px; }
.pen-mark.is-sm path { stroke-width: 2.6; }
.pen-mark.is-sm .pen-mark-text { font-size: 1.05rem; }
.pen-mark.is-drawn path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: pen-draw .9s var(--ease) .15s forwards; }
.pen-mark.is-drawn .pen-mark-text { opacity: 0; animation: pen-text .35s ease .75s forwards; }
@keyframes pen-draw { to { stroke-dashoffset: 0; } }
@keyframes pen-text { from { opacity: 0; transform: rotate(-4deg) scale(.9); } to { opacity: 1; transform: rotate(-4deg) scale(1); } }

/* ---------- Modal, bildirim ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(17, 25, 40, .52); animation: fade-in .18s ease;
}
.modal-panel {
  position: relative; width: min(640px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow: auto; overscroll-behavior: contain; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: rise-in .26s var(--ease);
}
.modal-panel.is-sm { width: min(420px, 100%); }
.modal-body { padding: 22px; }
.modal-title { font-size: 1.15rem; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
@media (max-width: 640px) {
  .modal { padding: 0; align-items: end; }
  .modal-panel { width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 94vh; max-height: 94dvh; }
}
.toast-stack {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 250;
  display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none;
}
.toast {
  display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px;
  background: #1b2230; color: #fff; font-size: .92rem; box-shadow: var(--shadow); pointer-events: auto;
  animation: rise-in .25s var(--ease);
}
.toast .icon { color: var(--marker); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--ink-soft); border-top-color: var(--ink); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; }
  .pen-mark.is-drawn path { stroke-dashoffset: 0; }
  .pen-mark.is-drawn .pen-mark-text { opacity: 1; }
}
