/* Palette inspired by the German flag: black, red, gold. */
:root {
  --ink: #1c1c1c;        /* flag black: header, footer, headings */
  --red: #b00000;        /* flag red, darkened for text contrast: links, buttons */
  --red-dark: #7f0000;
  --gold: #ffce00;       /* flag gold: accents on dark backgrounds and stripes */
  --gold-dark: #c9a227;  /* gold that still shows on light backgrounds */
  --gold-soft: #fff6d1;  /* hover / highlight backgrounds */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.6;
  color: #222;
  background: #f4f4f0;
  /* at least one screen tall, so the footer sits at the bottom of short pages */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body > main {
  flex: 1 0 auto;
  width: 100%;
}

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

a:hover {
  color: var(--red-dark);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: var(--ink);
}

/* red and gold stripe under the black bar: the flag, read top to bottom */
.site-header::after {
  content: "";
  display: block;
  height: 6px;
  background: linear-gradient(var(--red) 0 50%, var(--gold) 50% 100%);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.logo {
  color: #fff;
  font-size: 24px;
  font-weight: bold;
  text-decoration: none;
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap; /* more sections than fit one line on phones */
  gap: 4px 20px;
}

nav a {
  color: #fff;
  text-decoration: none;
}

nav a:hover,
nav a[aria-current="page"] {
  text-decoration: underline;
}

nav a[aria-current="page"] {
  color: var(--gold);
}

/* Content */
/* Homepage: header, content and footer fit one screen. The content has three
   rows: intro at the top, features at the bottom and the banner in between;
   the two outer rows share the free space equally, so the banner sits in
   the middle of the content area whatever the screen size. */
body > main.home {
  /* faint outline of Germany behind the content (web/germany.svg) */
  background: url("/germany.svg") center / contain no-repeat;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  gap: clamp(12px, 3vh, 28px);
  padding-top: clamp(12px, 3vh, 28px);
  padding-bottom: clamp(12px, 3vh, 28px);
}

main.home > * {
  margin: 0;
}

main.home .intro {
  align-self: start;
  /* one row on wide screens: text on the left, button on the right */
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 24px;
  padding: clamp(14px, 3vh, 24px) 24px;
}

main.home .intro h1 {
  margin-bottom: 4px;
}

main.home .intro p {
  margin: 0;
}

main.home .intro p:last-child {
  grid-column: 2;
  grid-row: 1 / span 2;
}

main.home .features {
  align-self: end;
}

main.home .banner {
  justify-self: center;
}

.banner-ro {
  display: block;
  margin-top: 6px;
  font-size: max(14px, 0.45em);
  font-style: italic;
  color: #8a7a40;
}

/* Phones and short screens: the feature boxes keep only their titles,
   side by side, so the homepage still fits without scrolling. */
@media (max-width: 700px), (max-height: 700px) {
  main.home .features {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  main.home .features .box {
    padding: 8px 10px;
    text-align: center;
  }

  main.home .features .box h2 {
    font-size: 16px;
    margin: 0;
  }

  main.home .features .box p {
    display: none;
  }
}

@media (max-width: 700px) {
  main.home .intro {
    grid-template-columns: 1fr;
    padding: 14px 16px;
  }

  main.home .intro h1 {
    font-size: 24px;
  }

  main.home .intro p {
    font-size: 15px;
  }

  main.home .intro p:last-child {
    grid-column: 1;
    grid-row: auto;
    margin-top: 10px;
  }

  main.home .banner {
    font-size: 22px;
  }
}

/* Very short phones (e.g. 360x640): drop the intro sentence, keep the button. */
@media (max-width: 700px) and (max-height: 680px) {
  main.home .intro p:not(:last-child) {
    display: none;
  }

  /* homepage footer: only the bottom line, which still says "independent" */
  main.home ~ .site-footer .footer-main {
    display: none;
  }
}

.banner {
  pointer-events: auto;
}

.banner {
  width: 100%;
  max-width: 900px;
  margin: 0;
  /* slightly see-through, so the map behind the homepage shows faintly */
  background: rgba(253, 246, 227, 0.85);
  border: 1px solid #e0c97f;
  border-left: 6px solid var(--gold-dark);
  color: #4d3b00;
  font-size: clamp(24px, 5vw, 48px);
  line-height: 1.3;
  text-align: center;
  padding: clamp(14px, 3vh, 40px) clamp(16px, 4vw, 48px);
}

/* main.container, not main: a bare element selector loses to .container's padding */
main.container {
  padding-top: 30px;
  padding-bottom: 30px;
}

section {
  margin-bottom: 30px;
}

h1,
h2 {
  font-weight: normal;
  color: var(--ink);
}

h1 {
  font-size: 32px;
  margin: 0 0 10px;
}

h2 {
  font-size: 22px;
  margin: 0 0 8px;
}

.intro {
  background: #fff;
  border: 1px solid #ccc;
  padding: 24px;
}

.button {
  display: inline-block;
  background: var(--red);
  color: #fff;
  padding: 8px 18px;
  border: 1px solid var(--red-dark);
  text-decoration: none;
}

.button:hover {
  background: var(--red-dark);
  color: #fff;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.box {
  background: #fff;
  border: 1px solid #ccc;
  padding: 16px;
}

/* the whole box is the link */
a.box {
  display: block;
  color: inherit;
  text-decoration: none;
  border-bottom: 3px solid #ccc;
}

a.box:hover,
a.box:focus-visible {
  border-color: var(--red);
}

a.box:hover h2,
a.box:focus-visible h2 {
  color: var(--red);
}

a.box h2::after {
  content: " →";
  color: var(--gold-dark);
}

.box p {
  margin: 0;
}

/* Verbs page */
.legend {
  font-size: 15px;
  color: #555;
}

.prefix {
  color: #8b1a1a;
  font-weight: bold;
}

.aux-sein {
  color: #2e6b2e;
  font-weight: bold;
}

.search-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  background: #fff;
  border: 1px solid #ccc;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  min-width: 0;
  max-width: 360px;
  font: inherit;
  padding: 6px 8px;
  border: 1px solid #999;
}

.search-bar input:focus {
  outline: 2px solid var(--red);
  outline-offset: -1px;
}

.count {
  font-size: 15px;
  color: #555;
}

.verbs {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #ccc;
}

.verbs th,
.verbs td {
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #ddd;
}

.verbs th {
  position: sticky;
  top: 0;
  background: #e4e4de;
  border-bottom: 3px solid var(--gold-dark);
  font-size: 15px;
}

.verbs tbody tr:nth-child(even) {
  background: #f8f8f5;
}

.verbs tbody tr:hover {
  background: var(--gold-soft);
}

.verbs td:last-child {
  font-style: italic;
  color: #444;
}

.loader {
  text-align: center;
  color: #777;
  font-size: 15px;
  padding: 16px 0;
}

.no-results {
  text-align: center;
  color: #555;
  padding: 24px 0;
}

/* Nouns: article coloured by gender, the usual colours in German textbooks */
.art-der,
.art-die,
.art-das {
  font-weight: bold;
}

.art-der {
  color: #1f5fbf;
}

.art-die {
  color: #b00000;
}

.art-das {
  color: #2e7d32;
}

.verbs td.muted,
.forms dd.muted {
  color: #888;
  font-style: italic;
}

/* Full conjugation table, opened under a verb */
.verb-toggle {
  background: none;
  border: 0;
  padding: 0;
  margin-left: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: normal;
  color: #888;
  text-decoration: underline;
  cursor: pointer;
}

.verb-toggle:hover,
.verb-toggle[aria-expanded="true"] {
  color: var(--red);
}

.verbs td.conj {
  background: #fbfbf8;
  font-style: normal;
  color: inherit;
  padding: 4px 12px 14px;
}

.conjugation h4 {
  font-size: 16px;
  font-weight: normal;
  color: var(--ink);
  margin: 12px 0 6px;
}

.tense-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.more-tenses {
  margin-top: 12px;
}

.more-tenses summary {
  cursor: pointer;
  color: var(--red);
  text-decoration: underline;
  font-size: 15px;
}

.tense {
  background: #fff;
  border: 1px solid #ddd;
  padding: 6px 10px;
}

.tense-name {
  font-weight: bold;
  font-size: 14px;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}

.tense dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0 10px;
  margin: 0;
  font-size: 15px;
}

.tense dt {
  color: #777;
}

.tense dd {
  margin: 0;
}

/* Random verb */
.random-box {
  margin-bottom: 20px;
}

.random-card {
  background: #fff;
  border: 1px solid #ccc;
  border-left: 4px solid var(--gold-dark);
  padding: 16px 20px;
  margin-top: 12px;
}

.random-card h2 {
  font-size: 26px;
  margin-bottom: 8px;
}

.random-card h2 .verb-toggle {
  vertical-align: middle;
}

.random-conj {
  margin-top: 12px;
  padding-top: 4px;
  border-top: 1px solid #eee;
}

.random-card h3 {
  font-size: 17px;
  margin: 16px 0 6px;
}

.forms {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 16px;
  margin: 0;
}

.forms dt {
  color: #777;
}

.forms dd {
  margin: 0;
}

.example-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.example-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.example-list li:last-child {
  border-bottom: 0;
}

.example-list .de {
  display: block;
  font-size: 18px;
}

.example-list .tr {
  display: block;
  font-style: italic;
  color: #555;
}

.example-list .hl {
  font-weight: bold;
  color: var(--red);
}

.lang-tag {
  font-style: normal;
  font-size: 12px;
  border: 1px solid #bbb;
  padding: 0 4px;
  color: #666;
}

.attribution {
  margin-top: 12px;
}

.warning {
  background: #fdf6e3;
  border: 1px solid #e0c97f;
  color: #6b5200;
  font-size: 15px;
  padding: 8px 12px;
  margin: 10px 0 0;
}

/* Admin */
.admin-header {
  background: #333;
  border-bottom-color: #111;
}

.inline-form {
  display: inline;
  margin: 0;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: #fff;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

button.button {
  font: inherit;
  cursor: pointer;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.admin-toolbar h1 {
  margin: 0;
}

.notice {
  background: #e8f3e8;
  border: 1px solid #9c9;
  color: #234d23;
  padding: 8px 12px;
}

.admin-verbs td.ro {
  font-style: italic;
  color: #444;
}

.admin-verbs td:last-child {
  font-style: normal;
  white-space: nowrap;
}

.admin-verbs td.meta {
  font-size: 14px;
  color: #666;
}

.form-box {
  background: #fff;
  border: 1px solid #ccc;
  padding: 20px 24px;
  max-width: 560px;
}

.form-box.narrow {
  max-width: 380px;
  margin: 20px auto;
}

.form-box label {
  display: block;
  font-weight: bold;
  margin-top: 14px;
}

.form-box select {
  display: block;
  font: inherit;
  padding: 6px 8px;
  margin-top: 4px;
  border: 1px solid #999;
  background: #fff;
}

.form-box label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
}

.form-box label.checkbox input {
  display: inline;
  width: auto;
  margin: 0;
}

.form-box input {
  display: block;
  width: 100%;
  font: inherit;
  padding: 6px 8px;
  margin-top: 4px;
  border: 1px solid #999;
}

.form-box input:focus {
  outline: 2px solid var(--red);
  outline-offset: -1px;
}

.hint {
  font-size: 14px;
  color: #666;
  margin: 4px 0 0;
}

.form-error,
.field-error {
  color: #8b1a1a;
}

.form-error {
  background: #f9eceb;
  border: 1px solid #d9a3a3;
  padding: 8px 12px;
}

.field-error {
  font-size: 14px;
  margin: 4px 0 0;
}

.examples-admin {
  margin-top: 20px;
}

.link-button.danger {
  color: #8b1a1a;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

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

/* Footer */
.site-footer {
  background: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  color: #bbb;
}

/* the same red and gold stripe as under the header, closing the page */
.site-footer::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(var(--red) 0 50%, var(--gold) 50% 100%);
}

.site-footer a {
  color: var(--gold);
}

.site-footer p {
  margin: 0;
}

/* about text on the left, sources on the right */
.footer-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 48px;
  padding-top: 16px;
  padding-bottom: 14px;
}

.footer-about {
  max-width: 520px;
}

.footer-brand,
.footer-heading {
  color: #fff;
  font-weight: bold;
  margin-bottom: 2px;
}

.footer-sources ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-bottom {
  border-top: 1px solid #333;
  font-size: 13px;
  color: #888;
}

.footer-bottom .container {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Mobile */
@media (max-width: 700px) {
  body {
    font-size: 16px;
  }

  .container {
    padding: 0 16px;
  }

  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  /* phones: one column, and tighter so the homepage still fits one screen */
  .site-footer .footer-main {
    grid-template-columns: 1fr;
    gap: 6px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* the name is already in the line at the bottom */
  .footer-brand {
    display: none;
  }

  /* sources on one line: "Surse: Exemple: Tatoeba (…) · Conjugare: ablaut" */
  .footer-sources > *,
  .footer-sources li {
    display: inline;
  }

  .footer-heading::after {
    content: ":";
  }

  .footer-sources li + li::before {
    content: " · ";
  }

  h1 {
    font-size: 26px;
  }

  .intro {
    padding: 16px;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .button {
    display: block;
    text-align: center;
  }

  /* Verbs table becomes one card per verb */
  .search-bar input {
    max-width: none;
  }

  .verbs,
  .verbs tbody,
  .verbs tr,
  .verbs td {
    display: block;
  }

  .verbs {
    background: none;
    border: 0;
  }

  .verbs thead {
    display: none;
  }

  .verbs tr,
  .verbs tbody tr:nth-child(even) {
    background: #fff;
    border: 1px solid #ccc;
    margin-bottom: 10px;
    padding: 8px 12px;
  }

  .verbs tr[hidden] {
    display: none;
  }

  .verbs td {
    position: relative;
    padding: 2px 0 2px 84px;
    border: 0;
  }

  .verbs td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 3px;
    font-size: 14px;
    font-style: normal;
    color: #777;
  }

  .verbs td:first-child {
    font-size: 19px;
    padding-left: 0;
    padding-bottom: 6px;
  }

  .verbs td:first-child::before {
    content: none;
  }

  .verbs td.actions,
  .verbs td.no-results,
  .verbs td.conj {
    padding-left: 0;
  }

  .verbs td.conj::before {
    content: none;
  }

  /* the open conjugation sits right under its card */
  .verbs tr.conj-row,
  .verbs tbody tr.conj-row:nth-child(even) {
    margin-top: -11px;
    border-top: 0;
    padding: 0 12px 8px;
  }

  .verbs td.conj {
    padding: 0;
    background: none;
  }

  .verbs td.actions {
    padding-top: 6px;
  }

  .verbs td.actions::before,
  .verbs td.no-results::before {
    content: none;
  }

  .form-box {
    padding: 16px;
  }
}

/* Word list pages (verbs, nouns): larger type everywhere in the content (lists, conjugation
   tables, examples), for easier reading while learning. */
body.word-page main {
  font-size: 19px;
}

body.word-page .verbs th {
  font-size: 17px;
}

body.word-page .legend,
body.word-page .count,
body.word-page .loader,
body.word-page .warning {
  font-size: 17px;
}

body.word-page .hint {
  font-size: 16px;
}

body.word-page .verb-toggle {
  font-size: 15px;
}

body.word-page .random-card h2 {
  font-size: 30px;
}

body.word-page .random-card h3 {
  font-size: 20px;
}

body.word-page .example-list .de {
  font-size: 21px;
}

body.word-page .conjugation h4 {
  font-size: 19px;
}

body.word-page .more-tenses summary {
  font-size: 17px;
}

body.word-page .tense-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

body.word-page .tense-name {
  font-size: 17px;
}

body.word-page .tense dl {
  font-size: 18px;
}

body.word-page .lang-tag {
  font-size: 13px;
}

@media (max-width: 700px) {
  body.word-page main {
    font-size: 18px;
  }

  body.word-page .verbs td::before {
    font-size: 15px;
  }

  body.word-page .verbs td {
    padding-left: 90px;
  }

  body.word-page .verbs td:first-child,
  body.word-page .verbs td.conj,
  body.word-page .verbs td.no-results {
    padding-left: 0;
  }

  body.word-page .verbs td:first-child {
    font-size: 21px;
  }
}
