/* Word Per Day — design system v1 */
:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --ink-mute: #7a7a7a;
  --line: #e6e3dc;
  --brand: #ff7a45;
  --brand-ink: #b8421a;
  --accent: #4a7fff;
  --good: #34a853;
  --warn: #f5b400;
  --score-bg: #fff4e6;
  --score-ink: #b8421a;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 2px 6px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --surface: #1d1c18;
    --surface-2: #25241f;
    --ink: #f5f3ee;
    --ink-soft: #c7c4bd;
    --ink-mute: #8a8780;
    --line: #2e2c27;
    --brand: #ff9468;
    --brand-ink: #ffb892;
    --accent: #7da4ff;
    --score-bg: #2a221b;
    --score-ink: #ffb892;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 480px) {
  .container, .container-narrow { padding: 0 16px; }
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 22px;
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  width: 36px; height: 36px;
  display: block;
  box-shadow: var(--shadow-sm);
  border-radius: 10px;
}
.nav { display: flex; gap: 24px; align-items: center; }
.nav a { color: var(--ink-soft); font-weight: 500; font-size: 15px; }
.nav a:hover { color: var(--brand-ink); text-decoration: none; }

.nav-toggle {
  display: none;
  background: transparent; border: 0; padding: 8px; cursor: pointer;
  width: 40px; height: 40px;
  flex-direction: column; justify-content: space-between; align-items: center;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px; background: var(--ink);
  border-radius: 2px; transition: transform 200ms ease, opacity 200ms ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
  .site-header .container { height: 56px; }
  .brand { font-size: 18px; }
  .brand-mark { width: 32px; height: 32px; font-size: 16px; }
  .nav-toggle { display: flex; }
  .nav {
    position: fixed; top: 56px; left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 8px 16px 16px;
    transform: translateY(-110%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow-md);
  }
  .nav a {
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 16px;
  }
  .nav a:last-child { border-bottom: 0; }
  .site-header.is-open .nav { transform: translateY(0); }
}

/* Hero */
.hero {
  padding: 56px 0 24px;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.15; margin: 0 0 12px;
  letter-spacing: -0.01em;
  word-wrap: break-word;
}
.hero p { color: var(--ink-soft); font-size: 18px; margin: 0 auto; max-width: 560px; }
@media (max-width: 640px) {
  .hero { padding: 32px 0 16px; }
  .hero p { font-size: 16px; }
}

/* Search box (unscrambler input) */
.search {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  display: flex; gap: 8px; align-items: center;
  box-shadow: var(--shadow-md);
  max-width: 560px; margin: 24px auto;
}
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  padding: 10px 14px; font-size: 18px; color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.search input::placeholder { color: var(--ink-mute); text-transform: none; letter-spacing: 0; }
@media (max-width: 480px) {
  .search { padding: 6px; }
  .search input { padding: 8px 10px; font-size: 16px; }
  .search .btn { padding: 10px 14px; font-size: 14px; }
}
.btn {
  background: var(--brand); color: #fff;
  border: 0; cursor: pointer;
  padding: 12px 22px; font-size: 15px; font-weight: 600;
  border-radius: var(--radius-sm);
  transition: transform 80ms ease, filter 80ms ease;
  font-family: var(--font);
}
.btn:hover { filter: brightness(0.95); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
}

/* Filter chips */
.chips {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 16px auto 0;
}
.chip {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px;
  font-size: 13px; color: var(--ink-soft); cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.chip:hover, .chip.active {
  background: var(--brand); color: #fff; border-color: var(--brand);
}

/* Section */
section { padding: 32px 0; }
section h2 {
  font-family: var(--font-display);
  font-size: 24px; margin: 0 0 16px;
  letter-spacing: -0.005em;
}
section h3 { font-size: 18px; margin: 24px 0 12px; }
@media (max-width: 640px) {
  section { padding: 24px 0; }
  section h2 { font-size: 20px; }
  section h3 { font-size: 16px; margin: 20px 0 10px; }
}

/* Word grid */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
@media (max-width: 480px) {
  .word-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
  .word-card { padding: 10px 12px; }
  .word-card .w { font-size: 15px; }
}
.word-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  transition: border-color 160ms ease, background 160ms ease;
}
.word-card:hover {
  border-color: var(--brand);
  background: var(--surface-2);
}
.word-card .w {
  font-weight: 600; font-size: 16px;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.word-card .pts {
  background: var(--score-bg);
  color: var(--score-ink);
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}

/* Length groups */
.length-group { margin: 32px 0; }
.length-group h3 {
  display: flex; align-items: baseline; gap: 8px;
}
.length-group .count {
  color: var(--ink-mute); font-size: 14px; font-weight: 400;
}

/* Internal link rows */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
@media (max-width: 480px) {
  .related-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .related-grid a { padding: 10px 12px; font-size: 13px; }
}
.related-grid a {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--ink); text-decoration: none;
  font-size: 14px;
  transition: background 120ms ease, color 120ms ease;
}
.related-grid a:hover {
  background: var(--brand); color: #fff;
  border-color: var(--brand);
}

/* FAQ */
.faq details {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 18px;
  margin-bottom: 8px;
}
.faq summary {
  cursor: pointer; font-weight: 600;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--ink-mute); font-size: 18px; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 10px 0 0; color: var(--ink-soft); }

/* Breadcrumb */
.crumb {
  font-size: 13px; color: var(--ink-mute);
  padding: 16px 0 0;
}
.crumb a { color: var(--ink-mute); }
.crumb a:hover { color: var(--brand-ink); }
.crumb span { margin: 0 8px; }

/* Ads */
.ad-slot {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--ink-mute);
  font-size: 12px;
  padding: 24px;
  margin: 24px 0;
  min-height: 90px;
  display: grid; place-items: center;
}

/* Game */
.game-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  max-width: 480px; margin: 0 auto;
}
@media (max-width: 480px) {
  .game-card { padding: 16px; }
}
.tile-row {
  display: flex; justify-content: center; gap: 8px; margin: 16px 0;
  flex-wrap: wrap;
}
.tile {
  width: 52px; height: 60px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 28px;
  text-transform: uppercase;
  color: var(--ink);
  cursor: grab;
  user-select: none;
  touch-action: none;            /* prevent scroll while dragging on mobile */
  -webkit-user-drag: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
  padding: 0;
}
.tile:hover { border-color: var(--brand); }
.tile.selected {
  border-color: var(--brand);
  background: var(--score-bg);
  box-shadow: 0 0 0 3px rgba(255, 122, 69, 0.18);
}
.tile.dragging {
  cursor: grabbing;
  z-index: 10;
  opacity: 0.95;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  transition: none;              /* follow the pointer 1:1 */
  border-color: var(--brand);
}
.tile.drop-target {
  border-color: var(--brand);
  background: var(--score-bg);
  transform: scale(1.04);
}
.tile.locked { background: var(--good); color: #fff; border-color: var(--good); cursor: default; }
.tile.locked:hover { border-color: var(--good); }
.tile.wrong { background: #d94545; color: #fff; border-color: #d94545; }
@media (max-width: 480px) {
  .tile-row { gap: 6px; }
  .tile { width: 44px; height: 52px; font-size: 22px; }
}
@media (max-width: 360px) {
  .tile-row { gap: 4px; }
  .tile { width: 40px; height: 48px; font-size: 20px; }
}

.game-actions {
  display: flex; gap: 8px; justify-content: center; margin-top: 16px;
}
.streak {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 12px; margin-top: 16px;
}
.streak-item { text-align: center; min-width: 0; }
.streak-item .n { font-size: 22px; font-weight: 700; color: var(--brand-ink); display: block; line-height: 1.2; }
.streak-item .l { font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.05em; }

/* Word page */
.word-hero {
  font-family: var(--font-display);
  font-size: clamp(40px, 8vw, 80px) !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
  color: var(--brand-ink);
}
.phonetic { font-size: 18px; margin: 0 0 8px; font-style: italic; }
.score-strip {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin: 12px 0 8px;
}
.score-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 6px 6px;
  min-width: 44px;
  text-align: center;
  position: relative;
}
.score-tile .letter {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
}
.score-tile .pts {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--score-ink);
  margin-top: 4px;
}
.meaning-block { margin: 16px 0; }
.part-of-speech {
  display: inline-block;
  background: var(--score-bg);
  color: var(--score-ink);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.defs { padding-left: 20px; margin: 0; }
.defs li { margin: 8px 0; line-height: 1.6; }
.def-text { color: var(--ink); }
.def-example {
  font-style: italic; color: var(--ink-mute);
  margin-top: 4px; padding-left: 12px;
  border-left: 2px solid var(--line);
  font-size: 14px;
}

/* Make word cards clickable links */
a.word-card { text-decoration: none; color: var(--ink); display: flex; }
a.word-card:hover { text-decoration: none; }

/* Footer */
.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 32px 0;
  color: var(--ink-mute);
  font-size: 14px;
}
.site-footer .container {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between;
  align-items: center;
}
.site-footer a { color: var(--ink-soft); }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px; row-gap: 6px; }
.footer-links a + a::before { content: "·"; color: var(--ink-mute); margin-right: 8px; }
@media (max-width: 640px) {
  .footer-links { font-size: 13px; }
}
@media (max-width: 640px) {
  .site-footer { margin-top: 40px; padding: 24px 0; }
  .site-footer .container { flex-direction: column; gap: 8px; text-align: left; }
}

/* Utility */
.muted { color: var(--ink-mute); }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
