/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e2e0d8;
  --text: #1a1a18;
  --muted: #6b6b60;
  --accent: #2d6a4f;
  --accent-light: #d8f3dc;
  --danger: #c0392b;
  --winner-gold: #b8860b;
  --winner-bg: #fffbea;
  --loser-color: #999;
  --mark-bg: #fff3cd;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}

html { font-size: 16px; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Header / Nav
   ============================================================ */
header {
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
}

.site-title {
  display: block;
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: normal;
  letter-spacing: -.02em;
  color: var(--text);
}

.site-title:hover { text-decoration: none; }


.back-link {
  display: inline-block;
  font-family: system-ui, sans-serif;
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ============================================================
   Main / Footer
   ============================================================ */
main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

footer {
  text-align: center;
  padding: 1rem;
  font-family: system-ui, sans-serif;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.footer-license {
  font-size: .7rem;
  color: var(--border);
  max-width: 720px;
  margin: .5rem auto 0;
  line-height: 1.5;
}

/* ============================================================
   Lock banner
   ============================================================ */
.lock-banner {
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  margin-top: -.75rem;
  margin-bottom: 1.75rem;
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  text-align: center;
}

.lock-banner--upcoming {
  background: #fff8e1;
  border: 1px solid #e6b800;
  color: #6b4c00;
}

.lock-banner--locked {
  background: #f3f3f1;
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ============================================================
   Banner (previous winner)
   ============================================================ */
.banner {
  background: var(--winner-bg);
  border: 1px solid #e6d97a;
  border-radius: var(--radius);
  padding: .6rem 1rem;
  margin-bottom: 1.5rem;
  font-family: system-ui, sans-serif;
  font-size: .9rem;
}

.banner-label { color: var(--muted); margin-right: .25rem; }
.banner-detail { color: var(--muted); margin: 0 .25rem; }

/* ============================================================
   Vote section
   ============================================================ */
.vote-section { text-align: center; }
.vote-heading { font-size: 1rem; font-family: system-ui, sans-serif; color: var(--muted); margin-top: .5rem; }

.main-word {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: normal;
  letter-spacing: -.02em;
  line-height: 1.1;
  margin-bottom: .25rem;
}

.definition {
  font-size: 1.05rem;
  color: var(--muted);
  font-style: italic;
  margin: 0 auto .5rem;
  max-width: 520px;
}

.synset-label {
  font-family: system-ui, sans-serif;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Ballot */
fieldset { border: none; padding: 0; max-width: 480px; margin: 0 auto; }
legend { display: none; }

.word-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .8rem;
  margin-bottom: .4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.25rem;
  transition: background .15s;
  background: var(--surface);
}

.word-option:hover { background: var(--accent-light); border-color: var(--accent); }
.word-option input[type="radio"] { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }

.vote-btn {
  margin-top: 1rem;
  padding: .65rem 2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: system-ui, sans-serif;
  cursor: pointer;
  transition: opacity .15s;
}
.vote-btn:hover { opacity: .85; }

/* Results */
.results { max-width: 480px; margin: 1rem auto 0; text-align: left; }

.result-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .5rem;
  font-family: system-ui, sans-serif;
  font-size: .95rem;
}

.result-word {
  width: 140px;
  flex-shrink: 0;
  font-size: 1.05rem;
  font-family: Georgia, serif;
}

.bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--border);
  border-radius: 9px;
  overflow: hidden;
}

.bar {
  height: 100%;
  background: var(--accent);
  border-radius: 9px;
  transition: width .4s ease;
  min-width: 2px;
}

.result-pct { width: 44px; text-align: right; font-size: .85rem; color: var(--muted); }
.result-count { font-size: .8rem; color: var(--muted); }

.my-vote .result-word { font-weight: bold; color: var(--accent); }
.my-vote .bar { background: #1a5c38; }

.your-vote-tag {
  font-size: .75rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
}

.vote-count-summary, .first-vote {
  margin-top: .5rem;
  font-family: system-ui, sans-serif;
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
}

.ends-at {
  margin-top: 1.25rem;
  font-family: system-ui, sans-serif;
  font-size: .8rem;
  color: var(--muted);
}

.no-round {
  font-family: system-ui, sans-serif;
  color: var(--muted);
  padding: 2rem 0;
}

#vote-blocks { transition: opacity 300ms ease; }
#vote-blocks.htmx-swapping { opacity: 0; }
#vote-blocks.htmx-settling { opacity: 0; }

/* ============================================================
   History
   ============================================================ */
h2 { font-size: 1.5rem; margin-bottom: 1.25rem; }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.history-winner {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
}

.trophy { font-size: 1.5rem; }
.winner-word { font-size: 1.4rem; font-weight: bold; color: var(--winner-gold); }

.history-words {
  list-style: none;
  margin-bottom: .75rem;
}

.history-words li {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .95rem;
  padding: .15rem 0;
  font-family: system-ui, sans-serif;
}

.history-words .hw { flex: 1; }
.history-words .winner .hw { font-weight: bold; color: var(--accent); }
.history-words .loser .hw { color: var(--muted); text-decoration: line-through; }
.hw-votes { font-size: .8rem; color: var(--muted); }
.hw-pct { font-size: .75rem; color: var(--muted); }

.history-meta {
  font-size: .75rem;
  font-family: system-ui, sans-serif;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  margin-top: .5rem;
}

/* ============================================================
   Dictionary
   ============================================================ */
.dict-intro { font-family: system-ui, sans-serif; font-size: .9rem; color: var(--muted); margin-bottom: 1rem; }

.az-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: 1.5rem;
}

.az-link {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: system-ui, sans-serif;
  font-size: .85rem;
  color: var(--muted);
  transition: background .15s;
}

.az-link:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }
.az-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.dict-list { display: flex; flex-direction: column; gap: .35rem; }

.dict-entry-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.dict-entry {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  font-size: 1rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.dict-entry::-webkit-details-marker { display: none; }
.dict-entry::marker { display: none; }

.dict-entry-wrap[open] > .dict-entry {
  border-bottom: 1px solid var(--border);
}

.dict-chevron {
  font-size: .75rem;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform .2s;
}

.dict-entry-wrap[open] .dict-chevron {
  transform: rotate(90deg);
}

.dict-group-detail {
  padding: .6rem .75rem .75rem;
}

.leading-bar { background: var(--winner-gold); }

.dict-word.winner { color: var(--text); }
.dict-word.loser s { color: var(--loser-color); }

.dict-badge.winner-badge {
  font-family: system-ui, sans-serif;
  font-size: .7rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
}

.dict-arrow { color: var(--muted); }
.dict-winner-ref { color: var(--accent); font-style: italic; }
.dict-votes { margin-left: auto; font-family: system-ui, sans-serif; font-size: .8rem; color: var(--muted); }

/* ============================================================
   Dictionary link
   ============================================================ */
.dict-link-wrap {
  text-align: center;
  margin: 2rem 0;
}

.dict-link-btn {
  display: inline-block;
  padding: .6rem 1.5rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-family: system-ui, sans-serif;
  font-size: .9rem;
  color: var(--accent);
  transition: background .15s, color .15s;
}

.dict-link-btn:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* ============================================================
   Poems
   ============================================================ */
.poem-intro { font-family: system-ui, sans-serif; font-size: .9rem; color: var(--muted); margin-bottom: 1.5rem; }

.refine-heading {
  margin-top: 2.5rem;
  margin-bottom: .4rem;
}

.refine-section .poem-intro {
  margin-bottom: 1rem;
}

.refine-textarea {
  display: block;
  width: 100%;
  padding: .75rem 1rem;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  margin-bottom: .75rem;
}

.refine-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.refine-btn {
  padding: .65rem 2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: system-ui, sans-serif;
  cursor: pointer;
  transition: opacity .15s;
}

.refine-btn:hover { opacity: .85; }

.refine-result-article {
  margin-top: 1.5rem;
}

.poems-section {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: .75rem;
  /* let cards extend past the main column edge on small screens */
  margin: 0 -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.poem-article {
  flex: 0 0 min(calc(90vw - 2.5rem), 760px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.poem-header { margin-bottom: 1rem; }
.poem-header h3 { font-size: 1.2rem; }
.poem-author { font-family: system-ui, sans-serif; font-size: .85rem; color: var(--muted); margin-top: .2rem; }

.poem-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.poem-col:first-child {
  padding-right: 2rem;
  border-right: 1px solid var(--border);
}

.poem-col:last-child {
  padding-left: 2rem;
}

.poem-col h4 {
  font-family: system-ui, sans-serif;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .75rem;
}

.poem-text { }
.poem-line {
  margin-bottom: .15rem;
  line-height: 1.7;
}

.poem-col-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.no-changes {
  font-family: system-ui, sans-serif;
  font-size: .85rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

mark {
  background: var(--mark-bg);
  padding: 0 2px;
  border-radius: 2px;
}

.replacement-legend {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.replacement-legend h4 {
  font-family: system-ui, sans-serif;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .75rem;
}

.replacement-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .8rem;
  list-style: none;
  font-family: system-ui, sans-serif;
  font-size: .85rem;
}

.replacement-list s { color: var(--loser-color); }

/* ============================================================
   Utilities
   ============================================================ */
.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;
}

.empty-state {
  font-family: system-ui, sans-serif;
  color: var(--muted);
  padding: 2rem 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  .poem-columns { grid-template-columns: 1fr; }
  .result-word { width: 100px; }
  .nav-links { gap: .75rem; }
}
