/* Ciupos — the palette and geometry of a Moldovan covor: deep red and black on a warm
   cream ground, with the diamond-and-zigzag motifs of the loom used as rules and bands.
   Hand-written, no framework, no build step. */

:root {
  --cream:   #f5efe2;
  --paper:   #fffdf7;
  --ink:     #1c1714;
  --ink-soft:#57493f;
  --red:     #a4161a;
  --red-deep:#6d0f13;
  --ochre:   #c08a2e;
  --green:   #3f5e47;
  --rule:    #ddd2bb;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --wrap: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cream:   #17120f;
    --paper:   #1e1814;
    --ink:     #f0e7d8;
    --ink-soft:#b5a08c;
    --red:     #e0585c;
    --red-deep:#c23a3f;
    --ochre:   #d9a843;
    --green:   #7fa889;
    --rule:    #3a2f27;
  }
}

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

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

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 1rem/1.6 var(--sans);
}

.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }

a { color: var(--red); text-underline-offset: 0.18em; }
a:hover { color: var(--red-deep); }

/* ── the woven band ─────────────────────────────────────────────────────────
   A row of diamonds, drawn with gradients rather than an image, so it scales
   and costs nothing. This is the motif that runs along the edge of a covor. */
.band {
  height: 10px;
  background:
    repeating-linear-gradient(135deg, var(--red) 0 6px, transparent 6px 12px),
    repeating-linear-gradient( 45deg, var(--red) 0 6px, transparent 6px 12px),
    var(--ochre);
  background-size: 12px 12px, 12px 12px, auto;
  opacity: .85;
}

/* ── masthead ───────────────────────────────────────────────────────────── */
.masthead { background: var(--paper); border-bottom: 1px solid var(--rule); }
.masthead .wrap {
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem;
  align-items: baseline; justify-content: space-between;
  padding-block: 1.1rem .9rem;
}
.wordmark { text-decoration: none; color: inherit; display: block; }
.wordmark-name {
  display: block; font-family: var(--serif); font-size: 1.9rem;
  letter-spacing: .01em; color: var(--red); line-height: 1;
}
/* The house slogan, in the register of every language-purism column ever printed in
   Romanian — which is the joke. */
.wordmark-sub {
  display: block; font-size: .78rem; letter-spacing: .09em;
  text-transform: lowercase; color: var(--ink-soft); margin-top: .3rem;
  font-style: italic;
}
.wordmark:hover .wordmark-sub { color: var(--red); }
.masthead nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.masthead nav a {
  text-decoration: none; color: var(--ink-soft);
  font-size: .95rem; padding-bottom: .2rem; border-bottom: 2px solid transparent;
}
.masthead nav a:hover { color: var(--red); }
.masthead nav a.here { color: var(--ink); border-bottom-color: var(--red); }
.masthead nav a.quiet { font-variant: small-caps; letter-spacing: .06em; }

main { padding-block: 2.5rem 4rem; min-height: 60vh; }

/* ── typography ─────────────────────────────────────────────────────────── */
h1 {
  font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 4vw, 2.7rem);
  margin: 0 0 .4rem; line-height: 1.12;
}
h2 {
  font-family: var(--serif); font-weight: 600; font-size: 1.45rem;
  margin: 2.75rem 0 .5rem;
}
.lede { max-width: 46rem; margin-bottom: 2.25rem; }
.lede p { color: var(--ink-soft); font-size: 1.06rem; margin: 0; }
.sub { color: var(--ink-soft); margin: 0 0 1rem; }

/* ── forms ──────────────────────────────────────────────────────────────── */
textarea, input, select, button {
  font: inherit; color: inherit;
}
textarea, input[type="search"], select {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .6rem .7rem;
}
textarea {
  width: 100%; resize: vertical; font-family: var(--serif); font-size: 1.15rem;
  line-height: 1.5;
}
textarea:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--ochre); outline-offset: 1px;
}
button {
  background: var(--red); color: #fff; border: 0; border-radius: 3px;
  padding: .6rem 1.4rem; cursor: pointer; letter-spacing: .02em;
}
button:hover { background: var(--red-deep); }
button[disabled] { opacity: .45; cursor: default; }

.controls { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: .7rem; }
.controls label { font-size: .9rem; color: var(--ink-soft); }
.controls select { margin-left: .4rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: .8rem; }
.hint { font-size: .88rem; color: var(--ink-soft); }

/* ── translation output ─────────────────────────────────────────────────── */
.output {
  margin-top: 2rem; background: var(--paper);
  border: 1px solid var(--rule); border-left: 4px solid var(--red);
  border-radius: 3px; padding: 1.25rem 1.4rem;
}
.translation {
  font-family: var(--serif); font-size: 1.35rem; line-height: 1.45;
  margin: 0;
}
.translation:empty { display: none; }

/* Interlinear glossing. Each word is its own three-row grid, so a line wraps
   between words and never inside one. `align-items: start` matters: without it
   the rows go ragged the moment one gloss is taller than its neighbours. */
.gloss {
  display: flex; flex-wrap: wrap; align-items: start;
  gap: .55rem 1.35rem; margin-top: 1.25rem;
  padding-top: 1.1rem; border-top: 1px dashed var(--rule);
}
.gloss:empty { display: none; }
.gloss-word {
  display: inline-grid; grid-template-rows: repeat(2, auto);
  row-gap: .15rem; justify-items: start;
}
.gloss-surface { font-family: var(--serif); font-size: 1.02rem; }
.gloss-label {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .04em;
  color: var(--green); text-transform: none;
}
.gloss-word.unknown .gloss-surface { color: var(--red); text-decoration: underline wavy; }

.diagnostics { list-style: none; margin: 1.1rem 0 0; padding: 0; }
.diagnostics:empty { display: none; }
.diagnostics li {
  font-size: .9rem; padding: .35rem 0 .35rem .85rem;
  border-left: 3px solid var(--ochre); margin-bottom: .35rem; color: var(--ink-soft);
}
.diagnostics li.error { border-left-color: var(--red); }
.diagnostics li code {
  font-family: var(--mono); font-size: .82rem; color: var(--ink);
  background: color-mix(in srgb, var(--ochre) 18%, transparent);
  padding: .05rem .3rem; border-radius: 2px; margin-right: .4rem;
}

/* ── example chips ──────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  font-family: var(--serif); font-size: .95rem;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 2px; padding: .4rem .7rem; cursor: pointer; color: var(--ink);
  text-align: left;
}
.chip:hover { border-color: var(--red); background: var(--paper); color: var(--red); }
.chip.canon { border-left: 3px solid var(--red); }

/* ── dictionary ─────────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.filters input[type="search"] { flex: 1 1 18rem; }
.count { color: var(--ink-soft); font-size: .9rem; margin: 1rem 0 .4rem; }

.tablewrap { overflow-x: auto; }
table.dictionary { width: 100%; border-collapse: collapse; font-size: .96rem; }
table.dictionary th {
  text-align: left; font-family: var(--sans); font-size: .76rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 2px solid var(--red); padding: .5rem .7rem;
  white-space: nowrap;
}
table.dictionary td {
  padding: .62rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: top;
  overflow-wrap: break-word;
}
/* Every cell carries its own column name, for the card layout further down. While
   there is a header to read, it is redundant. */
.colname { display: none; }
table.dictionary tr:hover td { background: var(--paper); }
.lemma { font-family: var(--serif); font-size: 1.1rem; color: var(--red); }
.lemma .pos { font-family: var(--sans); font-size: .7rem; color: var(--ink-soft); margin-left: .45rem; }
.literal { color: var(--ink-soft); font-style: italic; }
.literal .form { font-style: normal; font-family: var(--serif); color: var(--ink); }
.means { font-weight: 600; }
.means .ro { display: block; font-weight: 400; color: var(--ink-soft); font-size: .88rem; }
.tag {
  display: inline-block; font-size: .7rem; letter-spacing: .06em;
  border: 1px solid var(--rule); border-radius: 2px; padding: .05rem .35rem;
  color: var(--ink-soft); white-space: nowrap;
}
.tag.proposed { border-color: var(--ochre); color: var(--ochre); }
.derived { display: block; font-size: .85rem; color: var(--ink-soft); margin-top: .25rem; }
.derived b { font-family: var(--serif); color: var(--ink); font-weight: 600; }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1.5rem; }
.pager span { color: var(--ink-soft); font-size: .9rem; }

/* ── grammar ────────────────────────────────────────────────────────────── */
.domains { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.domain {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 3px solid var(--ochre); border-radius: 3px; padding: .8rem .9rem;
}
.domain .arrow { font-family: var(--serif); font-size: 1.02rem; }
.domain .arrow b { color: var(--red); }
.domain .arrow span { color: var(--ink-soft); margin-inline: .35rem; }
.domain p { margin: .4rem 0 0; font-size: .88rem; color: var(--ink-soft); }
.domain .n { float: right; font-size: .78rem; color: var(--ink-soft); }

.rulelist { list-style: none; counter-reset: rule; margin: 0; padding: 0; }
.rulelist li { counter-increment: rule; padding: 1.2rem 0; border-bottom: 1px solid var(--rule); }
.rulelist h3 {
  font-family: var(--serif); font-size: 1.2rem; margin: 0 0 .35rem; font-weight: 600;
}
.rulelist h3::before {
  content: counter(rule); color: var(--red); font-size: .85rem;
  margin-right: .6rem; vertical-align: .15em;
}
.rulelist p { margin: 0 0 .7rem; color: var(--ink-soft); max-width: 48rem; }
/* The first column is as wide as the example, but never wider than there is room
   for: `max-content` alone is the longest sentence in the data, which no page
   width bounds, and the overflow pushes the whole document sideways. */
.ex {
  display: grid; gap: .3rem .9rem; font-size: .94rem;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
}
.ex dt { font-family: var(--serif); color: var(--ink); }
.ex dd { margin: 0; color: var(--ink-soft); }

/* ── suggest a word ─────────────────────────────────────────────────────── */
.guide { margin: 0 0 2rem; padding-left: 1.3rem; max-width: 46rem; }
.guide li { margin-bottom: .55rem; color: var(--ink-soft); }
.guide b { color: var(--ink); }

.submit-form { max-width: 34rem; }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .9rem; margin-bottom: .3rem; }
.field input, .field textarea, .field select { width: 100%; }
.field small { display: block; margin-top: .25rem; font-size: .82rem; color: var(--ink-soft); }
.optional { color: var(--ink-soft); font-weight: 400; }

.result { margin-top: 1.25rem; padding: .8rem 1rem; border-left: 4px solid var(--rule); background: var(--paper); }
.result.good { border-left-color: var(--green); }
.result.bad { border-left-color: var(--red); }

/* ── footer ─────────────────────────────────────────────────────────────── */
footer { margin-top: 3rem; background: var(--paper); border-top: 1px solid var(--rule); }
.footer-inner { padding-block: 1.6rem 2.2rem; }
footer p { margin: 0; color: var(--ink-soft); font-size: .92rem; }
footer .creed {
  font-family: var(--serif); font-size: 1.15rem; color: var(--red);
  margin-bottom: .45rem; letter-spacing: .01em;
}
footer .meta { font-family: var(--mono); font-size: .76rem; margin-top: .5rem; opacity: .75; }

/* ── the narrow screen ──────────────────────────────────────────────────────
   Below 46rem the four columns of the dictionary are together narrower than
   their own contents — the table can only be read by dragging it sideways — so
   the table is put away and each entry is read as a card instead. The column
   names go with the header and come back as a label on each cell. */
@media (max-width: 46rem) {
  .tablewrap { overflow-x: visible; }
  table.dictionary thead { display: none; }
  table.dictionary,
  table.dictionary tbody,
  table.dictionary tr,
  table.dictionary td { display: block; }

  table.dictionary tr {
    background: var(--paper);
    border: 1px solid var(--rule); border-left: 3px solid var(--red);
    border-radius: 3px; padding: .85rem 1rem; margin-bottom: .75rem;
  }
  table.dictionary td { padding: 0; border-bottom: 0; }
  table.dictionary td + td { margin-top: .65rem; }

  .colname {
    display: block; font-family: var(--sans); font-size: .68rem;
    font-style: normal; font-weight: 400; letter-spacing: .1em;
    text-transform: uppercase; color: var(--ink-soft); margin-bottom: .12rem;
  }
  /* The word is the card's heading, and announces itself. */
  table.dictionary td:first-child .colname { display: none; }
  .lemma { font-size: 1.2rem; }
  /* Nothing here is in a column any more, so the tag may take two lines. */
  table.dictionary .tag { white-space: normal; }

  .pager { margin-top: 1.25rem; }
}

@media (max-width: 34rem) {
  .masthead .wrap { padding-block: .9rem .7rem; }
  .wordmark-name { font-size: 1.55rem; }
  main { padding-block: 1.75rem 2.5rem; }
  .gloss { gap: .5rem .9rem; }

  /* Past this width the gloss is squeezed into a column too narrow to read;
     set the example out above it instead. */
  .ex { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .ex dt:not(:first-child) { margin-top: .6rem; }
}
