/*
 * styles.css – Phosphor-Rechner der Katzothek
 *
 * Gestaltung angelehnt an katzothek.de und blog.katzothek.de:
 * Katzothek-Rot für Marke, Überschriften und Links, dunkles Grau für Text,
 * helles Grau als Seitenhintergrund, Olivgrün als ruhige Zweitfarbe.
 * Ergebniswerte bleiben bewusst neutral (dunkelgrau) – ein Phosphorwert
 * soll nicht wie eine Warnung aussehen. Bewusst nur helle Darstellung,
 * auch wenn das Betriebssystem auf dunkel steht (wie katzothek.de).
 *
 * Schriften: Yanone Kaffeesatz (Überschriften) und Roboto (Text) wie auf
 * katzothek.de, selbst gehostet unter assets/fonts/.
 */

/* ------------------------------------------------------------------ *
 * Design-Tokens
 * ------------------------------------------------------------------ */
:root {
  color-scheme: light;         /* Formularelemente und Scrollbars ebenfalls hell */
  --bg: #ececec;
  --surface: #ffffff;
  --surface-quiet: #f7f3f2;     /* warmes Hellgrau wie auf katzothek.de */
  --border: #dadada;
  --border-strong: #b5b5b5;
  --text: #313131;
  --text-muted: #5c5c5c;
  --brand: #d3050c;             /* Katzothek-Rot */
  --brand-strong: #a8040a;
  --on-brand: #ffffff;
  --accent: #4f6600;            /* Olivgrün, abgedunkelt für Textkontrast */
  --accent-soft: #f1f5e6;
  --accent-text: #4f6600;
  --warning: #b07d00;           /* Katzothek-Gelb, abgedunkelt; nur als Rahmen, Text bleibt dunkel */
  --warning-soft: #fff6d6;
  --error: #8f1d14;
  --error-soft: #fdecea;
  --focus: #4f6600;             /* bewusst nicht Rot, damit Fokus nicht wie ein Fehler wirkt */

  --radius: 6px;
  --radius-sm: 4px;
  --space: 1rem;
  --maxw: 60rem;

  --font: Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-display: "Yanone Kaffeesatz", "Roboto Condensed", "Avenir Next Condensed",
                  "Arial Narrow", sans-serif-condensed, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Markenschriften, selbst gehostet (SIL Open Font License, siehe
   assets/fonts/OFL-*.txt). Nur lateinischer Zeichensatz inkl. Umlaute;
   seltene Zeichen wie → oder ≈ kommen aus der Ersatzschrift.
   Keine Einbindung über Google Fonts (Datenschutz, siehe docs/deployment.md). */
@font-face {
  font-family: "Yanone Kaffeesatz";
  src: url("../fonts/yanone-kaffeesatz-700.woff2?v=59416886ba") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Roboto";
  src: url("../fonts/roboto-400.woff2?v=425c0713a8") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Roboto";
  src: url("../fonts/roboto-700.woff2?v=b9d66d1708") format("woff2");
  font-weight: 600 700;
  font-display: swap;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

h1, h2, h3, h4 { line-height: 1.25; text-wrap: balance; }
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
}
h1 {
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 0 0 .3em;
}
h2 { font-size: clamp(1.75rem, 4vw, 2.2rem); letter-spacing: .02em; margin: 0 0 .5em; }
h3 { font-size: 1.5rem; letter-spacing: .01em; margin: 2rem 0 .5em; }
h4 { font-size: 1rem; margin: 0 0 .5em; }

p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
li { margin-bottom: .35em; }

a {
  color: var(--brand);
  text-underline-offset: 2px;
  /* lange URLs (z. B. im Quellenteil) dürfen umbrechen, sonst entsteht
     auf schmalen Displays horizontales Scrollen */
  overflow-wrap: anywhere;
}
a:hover { text-decoration-thickness: 2px; }

code {
  font-family: var(--mono);
  font-size: .9em;
  overflow-wrap: anywhere;
  background: var(--surface-quiet);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1em .35em;
}

main > section { margin-block: 3rem; }

/* Sichtbare, deutliche Fokuszustände (Tastaturbedienung) */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: .75rem 1rem;
  z-index: 10;
  border: 1px solid var(--border-strong);
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ *
 * Header / Footer
 * ------------------------------------------------------------------ */
/* Markenleiste mit Logo und Verweisen auf die Katzothek */
.brand-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand-bar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1.5rem;
  padding-block: .75rem;
}
.brand { display: inline-block; line-height: 0; }
.brand-logo { display: block; width: auto; height: 5rem; }
@media (max-width: 26rem) { .brand-logo { height: 4rem; } }

.brand-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  margin: 0;
  padding: 0;
}
.brand-nav li { margin: 0; }
.brand-nav a {
  display: inline-block;
  padding-block: .35rem;
  color: var(--text);
  text-decoration: none;
  font-size: .95rem;
}
.brand-nav a:hover { color: var(--brand); text-decoration: underline; }
.lang-note { font-size: .8em; color: var(--text-muted); }

.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--brand);   /* rote Linie wie unter dem Katzothek-Header */
  padding-block: 2.25rem 2rem;
}

.eyebrow {
  margin: 0 0 .5rem;
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 1.25em;
}

.lead-list { margin-bottom: 1.25em; }

.privacy-note {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin: 0;
  font-size: .95rem;
}

.site-footer {
  border-top: 3px solid var(--brand);
  background: var(--surface);
  padding-block: 1.75rem;
  color: var(--text-muted);
  font-size: .9rem;
}
.site-footer p { margin: 0 0 .5rem; }
.footer-brand { color: var(--text); font-weight: 700; }

/* Links im Footer: durch einen Mittepunkt getrennt, auf schmalen
   Displays mit ausreichend grosser Klickflaeche. */
.footer-nav { margin-top: .75rem; }
.footer-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  margin: 0;
  padding: 0;
}
.footer-nav li { margin: 0; }
.footer-nav li + li::before {
  content: "·";
  margin-right: 1rem;
  color: var(--border-strong);
}
.footer-nav a {
  display: inline-block;
  padding-block: .25rem;
}

/* ------------------------------------------------------------------ *
 * Karten
 * ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card-quiet { background: var(--surface-quiet); }

.feeds { display: grid; gap: 1.25rem; }

.feed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.feed-title { margin: 0; font-size: 1.6rem; }

/* ------------------------------------------------------------------ *
 * Formular
 * ------------------------------------------------------------------ */
.field { margin-bottom: 1.25rem; }

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

.optional { font-weight: 400; color: var(--text-muted); }

input[type="text"], select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .7rem .75rem;
  min-height: 2.9rem;
}

select {
  /* eigener Pfeil, damit die Darstellung in beiden Themes stimmt */
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 55%, calc(100% - .7rem) 55%;
  background-size: .35rem .35rem, .35rem .35rem;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

input[aria-invalid="true"] {
  border-color: var(--error);
  background: var(--error-soft);
}

/* Wert und Einheit: auf sehr schmalen Displays untereinander, damit die
   Einheitenbezeichnung nicht abgeschnitten wird. */
.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .6rem;
}
@media (min-width: 26rem) {
  .input-row { grid-template-columns: minmax(0, 1fr) minmax(11rem, auto); }
}

.hint {
  margin: .4rem 0 0;
  font-size: .9rem;
  color: var(--text-muted);
}

.error {
  margin: .4rem 0 0;
  font-size: .9rem;
  color: var(--error);
  font-weight: 600;
}

.form-actions,
.feed-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-top: 1rem;
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: .65rem 1rem;
  min-height: 2.75rem;
}
.btn:hover { border-color: var(--brand); }

.btn-primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn-secondary:hover { background: var(--surface-quiet); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); text-decoration: underline; padding-inline: .25rem; }
.btn-small { font-size: .9rem; padding: .5rem .8rem; min-height: 2.4rem; }

.save-feedback { font-size: .9rem; color: var(--text-muted); }

/* ------------------------------------------------------------------ *
 * Ergebnisse
 * ------------------------------------------------------------------ */
.results {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (min-width: 42rem) {
  .results { grid-template-columns: 1fr 1fr; }
}

.result-card {
  background: var(--surface-quiet);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.result-card {
  border-top: 3px solid var(--accent);
}
.result-card h4 {
  color: var(--text-muted);
  font-size: .9rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.result-value {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 .4rem;
}

.result-note { font-size: .9rem; color: var(--text-muted); margin-bottom: .4rem; }
.result-sub { font-size: .85rem; color: var(--text-muted); margin: 0 0 .6rem; }
.result-extra {
  margin-top: 1rem;
  padding: .75rem 1rem;
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  font-size: .95rem;
}

/* Energieschaetzung */
.estimate {
  margin: -.5rem 0 1.25rem;
  background: var(--surface-quiet);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .35rem .9rem;
}
.estimate[open] { padding-bottom: .9rem; }
.estimate-intro { margin-top: 0; margin-bottom: .9rem; }
.estimate-grid { display: grid; gap: 0 1rem; }
@media (min-width: 30rem) { .estimate-grid { grid-template-columns: 1fr 1fr; } }
.estimate-grid .field { margin-bottom: .9rem; }
.estimate-status {
  margin: .25rem 0 .5rem;
  font-weight: 600;
}
.estimate-status:empty { display: none; }
.estimate-status[data-state="ok"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .55rem .8rem;
}
.estimate-extra { display: block; margin-top: .35rem; font-weight: 400; font-size: .9rem; }
.estimate-status[data-state="info"] { color: var(--text-muted); font-weight: 400; }
.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: .05rem .5rem;
  margin-left: .4rem;
}

.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.result-actions:not(:has(button:not([hidden]))) { display: none; }

.steps { margin-top: .5rem; }
.step-list { margin: .5rem 0 0; font-size: .9rem; }
.step-list li { margin-bottom: .3rem; }

details > summary {
  cursor: pointer;
  font-weight: 600;
  padding: .35rem 0;
}
details > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.details-body { padding-top: .5rem; }

#referenzwerte {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
}

/* ------------------------------------------------------------------ *
 * Vergleichstabelle (auf kleinen Displays als Karten)
 * ------------------------------------------------------------------ */
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
th { background: var(--surface-quiet); font-size: .85rem; }
.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 40rem) {
  /* Kartenlayout: jede Zeile wird zu einer Karte mit Beschriftungen */
  #comparison-table, #comparison-table tbody, #comparison-table tr, #comparison-table td {
    display: block;
    width: 100%;
  }
  #comparison-table thead { display: none; }
  #comparison-table { border: 0; background: transparent; }
  #comparison-table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .85rem;
    padding: .35rem .25rem;
  }
  #comparison-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    text-align: right;
    border-bottom: 1px dashed var(--border);
  }
  #comparison-table td:last-child { border-bottom: 0; }
  #comparison-table td::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
    color: var(--text-muted);
  }
  #comparison-table td[data-label="Futter"] { font-weight: 700; }
}

/* Sortierung */
.sort-control { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; margin-bottom: .75rem; }
.sort-control label { margin: 0; }
.sort-control select { width: auto; min-width: 16rem; max-width: 100%; }
.sort-btn {
  font: inherit;
  font-weight: 700;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.sort-btn:hover { color: var(--brand); }
th[aria-sort] .sort-btn { color: var(--brand); text-decoration: none; }
th[aria-sort="ascending"] .sort-btn::after { content: "\00a0▲"; font-size: .75em; font-family: system-ui, sans-serif; }
th[aria-sort="descending"] .sort-btn::after { content: "\00a0▼"; font-size: .75em; font-family: system-ui, sans-serif; }

/* Teilen */
.share-result {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.share-result .input-row { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 30rem) { .share-result .input-row { grid-template-columns: minmax(0, 1fr) auto; } }
.notice {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin: 0 0 1.25rem;
}

/* Bearbeiten gespeicherter Futter */
.linked-note {
  margin: 1rem 0 0;
  font-size: .9rem;
  color: var(--text-muted);
  border-left: 4px solid var(--brand);
  padding: .35rem .75rem;
}
.saved-list li.is-editing { border-color: var(--brand); box-shadow: inset 4px 0 0 var(--brand); }

/* ------------------------------------------------------------------ *
 * Gespeicherte Futtersorten
 * ------------------------------------------------------------------ */
.saved-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.saved-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
  margin: 0;
}
.saved-meta { font-size: .9rem; color: var(--text-muted); }
.saved-actions { display: flex; gap: .4rem; }

/* ------------------------------------------------------------------ *
 * Redaktioneller Teil
 * ------------------------------------------------------------------ */
.example-grid { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
@media (min-width: 40rem) { .example-grid { grid-template-columns: 1fr 1fr; } }

.kv { list-style: none; padding: 0; margin: 0 0 .5rem; }
.kv li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px dashed var(--border);
  padding: .3rem 0;
  margin: 0;
}
.kv li:last-child { border-bottom: 0; }

.formula-list { list-style: none; padding: 0; }
.formula-list li { margin-bottom: .45em; }

/* Quellenangabe direkt an der Aussage */
.cite {
  display: inline-block;
  font-size: .72em;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .02em;
  white-space: nowrap;
  vertical-align: .15em;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 .45em;
  text-decoration: none;
}
.cite:hover { background: var(--surface); text-decoration: underline; }
.sources li:target { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
.source-use { display: block; margin-top: .25rem; font-size: .9rem; color: var(--text-muted); }

/* Plausibilitaetshinweise unter Feldern */
.field-notes { margin-top: .45rem; }
.field-note {
  margin: 0 0 .35rem;
  font-size: .9rem;
  border-radius: var(--radius-sm);
  padding: .45rem .7rem;
}
.field-note-warning { background: var(--warning-soft); border-left: 4px solid var(--warning); color: var(--text); }
.field-note-info { background: var(--surface-quiet); border-left: 4px solid var(--border-strong); color: var(--text-muted); }

/* Sicherung */
.backup {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-strong);
}
.backup h4 { margin: 0 0 .25rem; }
.backup-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }

/* Haeufige Fragen */
.faq { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem 1.1rem;
}
.faq details[open] { padding-bottom: 1rem; }
.faq summary { display: flex; align-items: baseline; gap: .6rem; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; font-weight: 700; color: var(--brand); width: 1ch; flex: none; }
.faq details[open] summary::before { content: "−"; }
.faq summary h3 { display: inline; margin: 0; font-size: 1.45rem; }
.faq-table { margin-bottom: 1rem; }
.faq-table th, .faq-table td { padding: .55rem .6rem; }
.faq-table .num { white-space: nowrap; }

.sources { padding-left: 1.2em; }
.sources li { margin-bottom: .8em; }

.callout {
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
}
.callout-info { background: var(--surface-quiet); }
.callout-note { background: var(--surface-quiet); border-left: 4px solid var(--brand); color: var(--text); }
.callout-note h2 { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
