/* Lex: a scholar's notebook. Warm, bookish, calm, a little handmade.
   Flat shapes, hairline rules, no shadows or gradients. */

:root {
  --bg: #f4ead2;
  --surface: #fbf5e6;
  --ink: #2b2118;
  --ink-muted: #5e5041;
  --rule: #d8c9a3;
  --field-border: #8a7550;
  --green: #4a5a1f;
  --green-ink: #ffffff;
  --red: #9c2f1c;
  --brass: #8a6a1e;
  --brass-text: #765912;
  --focus: #1d3a5f;

  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Any class below that sets `display` would otherwise beat the browser's own
   rule for the `hidden` attribute, which play.js relies on. */
[hidden] {
  display: none !important;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 1.5rem;
}

a {
  color: var(--green);
}

a:visited {
  color: var(--green);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.site-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
}

.primary-nav {
  display: flex;
  gap: 1rem;
}

.primary-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.primary-nav a[aria-current="page"] {
  border-bottom-color: var(--green);
  font-weight: 600;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
  padding-inline: 1rem;
}

footer {
  max-width: 40rem;
  margin: 2rem auto 0;
  padding: 0.75rem 1rem 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

footer form {
  margin: 0;
}

/* Flash / status region */
.flash {
  border: 2px solid var(--green);
  background: var(--surface);
  color: var(--ink);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

/* Mascot images: signature detail, small, sparing */
.mascot {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
}

.button-primary {
  background: var(--green);
  color: var(--green-ink);
  border-color: var(--green);
}

.button-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.button-destructive-outline {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}

.button-destructive-solid {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

.button-full {
  width: 100%;
}

.button-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.top-add {
  margin-bottom: 1rem;
}

.quiet-link {
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

/* Search form */
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 12rem;
}

.search-form label {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

/* Word list: a ruled ledger, not cards */
.word-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.word-list li {
  border-bottom: 1px solid var(--rule);
}

.word-row {
  display: block;
  min-height: 44px;
  padding: 0.75rem 0.25rem;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.word-row:hover {
  background: var(--surface);
}

.word-row:active {
  background: var(--rule);
}

.word-headword {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
}

.word-pos {
  font-style: italic;
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 1rem;
}

.word-meaning {
  color: var(--ink);
  margin-top: 0.125rem;
}

.word-tags {
  margin-top: 0.375rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.tag {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  border: 1px solid var(--field-border);
  border-radius: 4px;
  padding: 0.0625rem 0.4rem;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  font-size: 0.9375rem;
}

.pagination .current-page {
  color: var(--ink-muted);
}

.pagination a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5rem;
}

/* Forms */
form .field {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  font-size: 1rem;
  font-family: var(--font-sans);
  padding: 0.5rem 0.625rem;
  border: 2px solid var(--field-border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.error-text {
  color: var(--red);
  font-weight: 600;
  font-size: 0.9375rem;
  margin-top: 0.25rem;
}

.error-summary {
  border: 2px solid var(--red);
  color: var(--red);
  font-weight: 600;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

/* Named by element so this outranks the input[type="text"] rule above. */
input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--red);
  border-width: 3px;
}

fieldset {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem;
  margin: 1.5rem 0 0;
}

legend {
  padding: 0 0.5rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.tag-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tag-button {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--brass);
  border-radius: 4px;
  padding: 0.375rem 0.625rem;
  min-height: 32px;
  cursor: pointer;
}

.hint {
  color: var(--ink-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 0;
}

.empty-state p {
  color: var(--ink-muted);
  max-width: 30rem;
  margin: 0 auto 1rem;
}

/* The search form stays folded away until it is wanted, so words come first. */
.search-disclosure {
  margin-block: var(--space-4, 1rem);
}

.search-disclosure > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
}

.search-disclosure > summary::before {
  content: "+";
  display: inline-block;
  width: 1.25rem;
  font-weight: 700;
}

.search-disclosure[open] > summary::before {
  content: "\2212";
}

.search-disclosure > summary::-webkit-details-marker {
  display: none;
}

.search-disclosure > summary {
  list-style: none;
}

/* Match ("Play") */
.status-message {
  border: 2px solid var(--brass);
  color: var(--ink);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

#signed-out p {
  margin: 0 0 0.75rem;
}

#match-picker .field {
  margin-bottom: 1rem;
}

#start-button {
  margin-bottom: 1rem;
}

.retry-label {
  color: var(--brass-text);
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.375rem;
}

.match-prompt {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  margin: 0 0 1rem;
}

.match-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 1rem;
}

.match-choice {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 0.625rem 1rem;
  font-size: 1.0625rem;
  font-family: var(--font-sans);
  font-weight: 500;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  border: 2px solid var(--field-border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.match-choice:disabled {
  cursor: default;
  opacity: 0.85;
}

.match-choice.is-correct {
  border-color: var(--green);
  border-width: 3px;
  font-weight: 700;
}

.match-choice.is-wrong {
  border-color: var(--red);
  border-width: 3px;
}

.match-result {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  margin-bottom: 1rem;
}

.match-result p {
  margin: 0 0 0.375rem;
}

.mascot-inline {
  width: 64px;
  height: 64px;
  flex: none;
  margin: 0;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.score-line {
  margin: 0;
  font-weight: 600;
}

#match-end {
  text-align: center;
  padding: 1rem 0;
}

#match-end .button-row {
  align-items: center;
}
