/*
 * base.css: layout and components.
 * Colours, fonts, sizes and corners all come from CSS variables, which are set
 * by the theme file in css/themes/. To restyle the site, edit a theme or
 * custom.css; you rarely need to change this file.
 */

/* Fallback values, used if a theme leaves something out. */
:root {
  --color-bg: #f7f7f5;
  --color-surface: #ffffff;
  --color-text: #1c1f1d;
  --color-muted: #5e6661;
  --color-border: #dfe3e0;
  --color-accent: #12704c;
  --color-accent-strong: #0b5538;
  --color-accent-soft: #e4f1ea;
  --color-accent-contrast: #ffffff;
  --color-header-bg: var(--color-surface);
  --color-focus: var(--color-accent);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-size-base: 17px;
  --line-height: 1.6;
  --headword-size: clamp(2.4rem, 7vw, 3.6rem);
  --radius: 12px;
  --radius-small: 7px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 6px 20px rgb(0 0 0 / 0.04);
  --max-width: 980px;
  --gutter: 20px;
  --color-scheme: light;
}

/* ---------- reset ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  color-scheme: var(--color-scheme);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
a { color: var(--color-accent); text-underline-offset: 0.18em; }
a:hover { color: var(--color-accent-strong); }

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

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px; top: -60px;
  padding: 8px 14px;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border-radius: var(--radius-small);
  z-index: 10;
}
.skip-link:focus { top: 8px; }

/* ---------- header ---------- */

.site-header {
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 28px;
  padding-top: 14px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--color-text);
}
.brand:hover { color: var(--color-text); }
.brand__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand__tagline { font-size: 0.85rem; color: var(--color-muted); }
.brand__tagline:empty { display: none; }

.search {
  display: flex;
  flex: 1 1 320px;
  max-width: 460px;
  gap: 8px;
}

.search__input {
  flex: 1;
  width: 0;       /* lets the box shrink on narrow screens; flex: 1 sets its real width */
  min-width: 0;
  padding: 10px 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
}
.search__input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }

.search__button,
.button {
  display: inline-block;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-accent-contrast);
  background: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-small);
  cursor: pointer;
  text-decoration: none;
}
.search__button:hover,
.button:hover { background: var(--color-accent-strong); border-color: var(--color-accent-strong); color: var(--color-accent-contrast); }

.button--ghost {
  background: transparent;
  color: var(--color-accent);
}
.button--ghost:hover { background: var(--color-accent-soft); color: var(--color-accent-strong); border-color: var(--color-accent); }

/* ---------- main + footer ---------- */

.site-main {
  flex: 1;
  padding-top: 36px;
  padding-bottom: 56px;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.85rem;
}
.site-footer__inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 18px;
  flex-wrap: wrap;
}

/* ---------- home page ---------- */

.intro { margin-bottom: 24px; }
.intro__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: -0.015em;
}
.intro__text { margin-top: 6px; color: var(--color-muted); font-size: 1.05rem; }
.intro__text:empty { display: none; }
.intro__actions { margin-top: 16px; }

.letter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.letter-nav__link {
  min-width: 38px;
  padding: 6px 10px;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
}
.letter-nav__link:hover { border-color: var(--color-accent); color: var(--color-accent); }
.letter-nav__link.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-contrast);
}

.results__status { color: var(--color-muted); font-size: 0.9rem; margin-bottom: 12px; }
.results__empty {
  padding: 28px;
  text-align: center;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
}

.word-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.word-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 10px;
  height: 100%;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.word-card:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.word-card__word {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}
.word-card__pos {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--color-muted);
}
.word-card__pos:empty { display: none; }
.word-card__translation {
  grid-column: 1 / -1;
  color: var(--color-muted);
}

/* ---------- word page ---------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 0.88rem;
  color: var(--color-muted);
}
.breadcrumb__link { color: var(--color-muted); }
.breadcrumb__current { color: var(--color-text); }

.entry {
  padding: clamp(22px, 4vw, 40px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.entry__header { padding-bottom: 22px; }
.entry__word {
  font-family: var(--font-display);
  font-size: var(--headword-size);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.entry__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 0;
  margin-top: 10px;
  color: var(--color-muted);
}
.entry__meta > span:empty { display: none; }
.entry__meta > span:not(:empty) ~ span:not(:empty)::before {
  content: "·";
  margin: 0 10px;
  color: var(--color-border);
  font-style: normal;
}
.entry__pos { font-style: italic; }
.entry__pron-label {
  margin-right: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Every visible section opens with a dividing line. */
.entry-section { padding: 22px 0; border-top: 1px solid var(--color-border); }

.entry-section__title {
  margin-bottom: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.translation-list {
  margin: 0;
  padding-left: 1.4em;
  font-size: 1.45rem;
  font-weight: 600;
}
.translation-list__item + .translation-list__item { margin-top: 2px; }
.translation-list__item:only-child { list-style: none; margin-left: -1.4em; }
.translation-list__item--missing { color: var(--color-muted); font-weight: 400; font-style: italic; }

.example-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.example {
  padding: 12px 16px;
  background: var(--color-bg);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
}
.example__text { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.example__translation { color: var(--color-muted); }
.example__note { margin-top: 4px; font-size: 0.85rem; font-style: italic; color: var(--color-muted); }
.example__translation:empty,
.example__note:empty { display: none; }

.forms-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin: 0;
}
.forms-list__row {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
}
.forms-list dt { font-size: 0.8rem; color: var(--color-muted); }
.forms-list dd { margin: 0; font-weight: 600; font-size: 1.05rem; }

/* Tenses and cases tables. The row labels sit in the first column. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
}

.inflection-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}
.inflection-table th,
.inflection-table td {
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}
.inflection-table tbody tr:last-child > * { border-bottom: 0; }

.inflection-table thead th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  background: var(--color-table-head, var(--color-bg));
  white-space: nowrap;
}
.inflection-table__corner { background: var(--color-table-head, var(--color-bg)); }

.inflection-table tbody th {
  width: 1%;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}
.inflection-table td {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
}
.inflection-table--simple td { width: 100%; }
.inflection-table tbody tr:hover { background: var(--color-accent-soft); }
.inflection-table__empty { color: var(--color-border); font-weight: 400; }

.entry-notes__text { max-width: 65ch; }

.entry__footer { display: grid; gap: 18px; padding-top: 22px; border-top: 1px solid var(--color-border); }
.entry__footer:not(:has(> :not([hidden]))) { display: none; }

.related__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.related__link { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.related__translation { color: var(--color-muted); font-size: 0.9rem; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tag {
  display: inline-block;
  padding: 3px 11px;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
  border-radius: 999px;
}
.tag:hover { background: var(--color-accent); color: var(--color-accent-contrast); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.pager__link {
  display: flex;
  flex-direction: column;
  max-width: 48%;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.pager__link:hover { border-color: var(--color-accent); color: var(--color-text); }
.pager__link--next { margin-left: auto; text-align: right; }
.pager__label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted); }
.pager__word { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }

/* ---------- not found ---------- */

.not-found { display: grid; gap: 16px; }
.not-found__title { font-family: var(--font-display); font-size: 2.2rem; }
.not-found__text { color: var(--color-muted); }

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  :root { --gutter: 16px; }

  /* Tables with several columns become one small card per row. */
  .inflection-table:not(.inflection-table--simple) thead { display: none; }
  .inflection-table:not(.inflection-table--simple),
  .inflection-table:not(.inflection-table--simple) tbody,
  .inflection-table:not(.inflection-table--simple) tr,
  .inflection-table:not(.inflection-table--simple) th,
  .inflection-table:not(.inflection-table--simple) td { display: block; width: auto; }
  .inflection-table:not(.inflection-table--simple) tr {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
  }
  .inflection-table:not(.inflection-table--simple) tbody tr:last-child { border-bottom: 0; }
  .inflection-table:not(.inflection-table--simple) tbody th {
    padding: 0 0 4px;
    border: 0;
    white-space: normal;
  }
  .inflection-table:not(.inflection-table--simple) td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 3px 0;
    border: 0;
  }
  .inflection-table:not(.inflection-table--simple) td::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--color-muted);
  }
  .inflection-table:not(.inflection-table--simple) td { text-align: right; }
  .inflection-table:not(.inflection-table--simple) .inflection-table__empty { display: none; }
  .site-header__inner { flex-direction: column; align-items: stretch; }
  .search { flex: none; width: 100%; max-width: none; }
  .site-main { padding-top: 24px; }
  .word-list { grid-template-columns: 1fr; }
}

@media print {
  .site-header, .site-footer, .pager, .letter-nav, .breadcrumb { display: none; }
  .entry { border: 0; box-shadow: none; padding: 0; }
}
