/* 100 Sentences — clean light theme, warm paper + terracotta accent */

:root {
  --bg: #faf7f2;
  --bg-elevated: #ffffff;
  --bg-muted: #f1ebe3;
  --bg-card: #fffdf9;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-faint: #a8a29e;
  --border: #e7e0d6;
  --border-strong: #d6cfc3;
  --accent: #c2410c;        /* terracotta */
  --accent-hover: #9a3412;
  --accent-soft: #ffedd5;
  --accent-ink: #9a3412;
  --teal: #0f766e;          /* secondary accent for Thai feel */
  --teal-soft: #ccfbf1;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 8px 24px rgba(28, 25, 23, 0.06);
  --shadow-card: 0 2px 8px rgba(28, 25, 23, 0.06), 0 12px 32px rgba(28, 25, 23, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font-ui: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-thai: "Noto Sans Thai", "Thonburi", "Sukhumvit Set", sans-serif;
  --font-en: "Source Serif 4", Georgia, "Times New Roman", serif;
  --space: 1rem;
  --max: 42rem;
  --header-h: 3.75rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 100% -20%, rgba(194, 65, 12, 0.06), transparent 50%),
    radial-gradient(ellipse 60% 40% at -10% 10%, rgba(15, 118, 110, 0.05), transparent 45%),
    var(--bg);
  display: flex;
  flex-direction: column;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: calc(var(--max) + 2rem);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent) 0%, #ea580c 100%);
  color: #fff;
  font-family: var(--font-thai);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-domain {
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.header-nav {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-muted);
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.nav-btn:hover {
  color: var(--ink);
}

.nav-btn.is-active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.08);
}

.nav-icon {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Main */
.main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--max) + 2rem);
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + var(--safe-bottom));
}

/* Controls */
.controls {
  margin-bottom: 1.25rem;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.direction-toggle {
  display: inline-flex;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.15rem;
}

.dir-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  gap: 0.1rem;
}

.dir-main {
  font-size: 0.8125rem;
  font-weight: 650;
}

.dir-sub {
  font-size: 0.65rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  opacity: 0.75;
}

.dir-btn.is-active .dir-sub {
  opacity: 0.9;
}

.dir-btn:hover {
  color: var(--ink);
}

.dir-btn.is-active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 1px 4px rgba(28, 25, 23, 0.2);
}

/* Toggle switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-ui {
  width: 2.5rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-ui {
  background: var(--teal);
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(1.1rem);
}

.toggle input:focus-visible + .toggle-ui {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.coming-soon {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-weight: 500;
}

/* Search */
.search-wrap {
  margin-bottom: 0.85rem;
}

.search-input {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
  color: var(--ink-faint);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

.result-count {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-weight: 500;
}

/* Sentence list */
.sentence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sentence-item {
  margin: 0;
}

.sentence-btn {
  width: 100%;
  text-align: left;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  display: grid;
  gap: 0.35rem;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.03);
}

.sentence-btn:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.sentence-btn:active {
  transform: scale(0.995);
}

.sentence-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.item-primary {
  font-size: 1.05rem;
  font-weight: 550;
  line-height: 1.4;
  color: var(--ink);
}

.item-primary.is-thai {
  font-family: var(--font-thai);
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.item-primary.is-en {
  font-family: var(--font-en);
  font-weight: 550;
}

.item-secondary {
  font-size: 0.875rem;
  color: var(--ink-soft);
  line-height: 1.35;
}

.item-secondary.is-thai {
  font-family: var(--font-thai);
  font-size: 0.95rem;
}

.item-translit {
  font-size: 0.8rem;
  color: var(--teal);
  font-style: italic;
  font-weight: 500;
}

.item-id {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ink-soft);
  font-weight: 500;
}

/* Flip cards */
.view-detail,
.view-practice {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.back-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0.35rem 0;
  margin-bottom: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.back-btn:hover {
  color: var(--accent);
}

.flip-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.5rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 18rem;
}

.card-face {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  padding: 1.5rem 0.5rem;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  color: inherit;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border-radius: var(--radius-sm);
  min-height: 10rem;
  transition: background 0.15s;
}

.card-face:hover {
  background: var(--bg-muted);
}

.card-face:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-prompt {
  margin: 0;
  font-size: clamp(1.35rem, 4.5vw, 1.85rem);
  line-height: 1.35;
  font-weight: 550;
  max-width: 28rem;
}

.card-prompt.is-thai {
  font-family: var(--font-thai);
  font-weight: 500;
  font-size: clamp(1.55rem, 5vw, 2.1rem);
  letter-spacing: 0.01em;
}

.card-prompt.is-en {
  font-family: var(--font-en);
  font-weight: 550;
}

.card-translit {
  margin: 0;
  font-size: 0.95rem;
  color: var(--teal);
  font-style: italic;
  font-weight: 500;
  line-height: 1.4;
}

.reveal-hint {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.card-answer {
  text-align: center;
  padding: 1rem 0.5rem 0.25rem;
  border-top: 1px dashed var(--border-strong);
  animation: revealIn 0.25s ease;
}

@keyframes revealIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.card-answer-text {
  margin: 0;
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  line-height: 1.4;
  font-weight: 550;
  color: var(--accent-ink);
}

.card-answer-text.is-thai {
  font-family: var(--font-thai);
  font-weight: 500;
  font-size: clamp(1.45rem, 4.5vw, 1.9rem);
  color: var(--teal);
}

.card-answer-text.is-en {
  font-family: var(--font-en);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
}

.card-actions .btn:first-child {
  justify-self: start;
}

.card-actions .btn:last-child {
  justify-self: end;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  min-width: 6.5rem;
}

.btn-primary:hover:not(:disabled) {
  background: #292524;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-muted);
  color: var(--ink);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}

.practice-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.practice-card {
  min-height: 20rem;
}

/* Footer */
.site-footer {
  max-width: calc(var(--max) + 2rem);
  margin: 0 auto;
  padding: 1rem 1rem calc(1.5rem + var(--safe-bottom));
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.75rem;
  font-weight: 500;
  border-top: 1px solid var(--border);
  width: 100%;
}

.site-footer p {
  margin: 0.2rem 0;
}

.footer-note {
  opacity: 0.85;
}

/* Highlight mark in search */
mark {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 2px;
  padding: 0 0.1em;
}

/* Mobile tweaks */
@media (max-width: 420px) {
  .brand-domain {
    display: none;
  }

  .nav-btn {
    padding: 0.45rem 0.7rem;
  }

  .dir-btn {
    padding: 0.35rem 0.65rem;
  }

  .dir-main {
    font-size: 0.75rem;
  }

  .toggle-label {
    font-size: 0.8rem;
  }

  .card-actions {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .card-actions .btn-primary,
  .card-actions .btn-accent {
    grid-column: 1 / -1;
    justify-self: stretch;
    order: -1;
  }

  .card-actions .btn:first-child {
    justify-self: stretch;
  }

  .card-actions .btn:last-child {
    justify-self: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Sentence row + know level ─────────────────────────────────── */

.sentence-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.03);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sentence-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.sentence-row .sentence-btn {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.sentence-row .sentence-btn:hover {
  border-color: transparent;
  box-shadow: none;
}

.know-level {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.know-level--list {
  padding: 0.55rem 0.7rem 0.55rem 0.25rem;
  align-self: center;
}

.know-level--card {
  justify-content: center;
  padding: 0.15rem 0.5rem 0.35rem;
  flex-wrap: wrap;
}

.know-level-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.know-boxes {
  display: inline-flex;
  gap: 0.28rem;
  align-items: center;
}

.know-box {
  appearance: none;
  width: 0.85rem;
  height: 0.85rem;
  padding: 0;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--bg-muted);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.1s, box-shadow 0.12s;
}

.know-level--list .know-box {
  width: 0.78rem;
  height: 0.78rem;
}

.know-level--card .know-box {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 4px;
}

.know-box:hover {
  border-color: var(--teal);
  transform: scale(1.08);
}

.know-box:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.know-box.is-filled {
  background: var(--teal);
  border-color: var(--teal);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--teal) 25%, transparent);
}

.know-box.is-filled:hover {
  background: #0d9488;
  border-color: #0d9488;
}

@media (max-width: 420px) {
  .know-level--list {
    padding: 0.45rem 0.55rem 0.45rem 0.15rem;
  }

  .know-level--list .know-box {
    width: 0.72rem;
    height: 0.72rem;
  }

  .know-boxes {
    gap: 0.22rem;
  }
}
