@layer reset, tokens, base, layout, components, utilities;

/* ---------- Farben und Maße ---------- */
@layer tokens {
  :root {
    color-scheme: light dark;

    --paper: #f3f6f2;
    --surface: #ffffff;
    --tint: #e4eee8;
    --ink: #1b2a38;
    --ink-soft: #4d5e6c;
    --line: #d3dcd6;
    --line-strong: #8b9aa3;
    --pine: #1d5a49;
    --pine-strong: #134034;
    --on-pine: #ffffff;
    --marigold: #f2b632;
    --up: #1d7a5f;
    --down: #b3355c;
    --none: #c4cec8;

    --font-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Young Serif", Georgia, "Times New Roman", serif;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --paper: #121d26;
      --surface: #1a2833;
      --tint: #1b3029;
      --ink: #e8eef2;
      --ink-soft: #a3b3bf;
      --line: #2b3c47;
      --line-strong: #6e8392;
      --pine: #6fcfae;
      --pine-strong: #92dcc2;
      --on-pine: #0d2a21;
      --up: #4fc9a4;
      --down: #f0829f;
      --none: #32444f;
    }
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, figure, dl, dd { margin: 0; }
  ul { padding: 0; }
  button, input, select { font: inherit; color: inherit; }
  svg { display: block; }
  [hidden] { display: none !important; }
}

/* ---------- Grundstil ---------- */
@layer base {
  html { font-size: 106.25%; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

  body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  main { flex: 1; }

  h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.1;
    text-wrap: balance;
  }

  h2 { font-size: clamp(1.7rem, 3.5vw, 2.2rem); }
  h3 { font-size: 1.3rem; }
  p { max-width: 62ch; text-wrap: pretty; }

  a { color: var(--pine); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
  a:hover { text-decoration-thickness: 2px; }

  ::selection { background: var(--marigold); color: #1b2a38; }

  :focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--marigold);
    border-radius: 0.25rem;
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
  }
}

/* ---------- Seitengerüst ---------- */
@layer layout {
  .wrap { width: min(72rem, 100% - 2rem); margin-inline: auto; }

  .site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1rem;
  }

  .hero { padding-block: clamp(2.25rem, 7vw, 4.5rem) clamp(1.75rem, 4vw, 2.75rem); }
  .picks { background: var(--tint); padding-block: clamp(1.75rem, 4vw, 2.75rem); }
  .directory { padding-block: clamp(2.5rem, 6vw, 4rem); }
  .about { padding-block: clamp(2.5rem, 6vw, 4rem); border-top: 1px solid var(--line); }
  .about-grid { display: grid; gap: 2rem 4rem; }
  .site-footer { padding-block: 1.75rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 0.9rem; }

  @media (min-width: 52rem) {
    .about-grid { grid-template-columns: 1fr 1fr; }
  }
}

/* ---------- Bausteine ---------- */
@layer components {
  .skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    background: var(--ink);
    color: var(--paper);
    padding: 0.6rem 1rem;
    border-radius: 0.4rem;
    z-index: 10;
  }
  .skip-link:focus { top: 0.75rem; }

  .wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--ink);
    text-decoration: none;
  }
  .wordmark-mark { width: 1.7rem; height: 1.15rem; }
  .wordmark-mark .m-a { fill: var(--pine); }
  .wordmark-mark .m-b { fill: var(--marigold); }

  .languages { display: flex; gap: 1.1rem; font-size: 0.95rem; }
  .languages a { color: var(--ink); text-decoration: none; padding-block: 0.4rem; }
  .languages a:hover { text-decoration: underline; }
  .languages a[aria-current="true"] {
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--marigold);
    text-decoration-thickness: 3px;
  }

  /* Einstieg */
  .hero h1 { font-size: clamp(2.8rem, 9vw, 5.5rem); letter-spacing: -0.01em; line-height: 1; }
  .lead { margin-top: 1.25rem; font-size: clamp(1.1rem, 2.2vw, 1.3rem); max-width: 44rem; }
  .summary { margin-top: 1rem; color: var(--ink-soft); }

  /* Empfehlungen */
  .picks-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 2rem;
    margin-bottom: 1.4rem;
  }
  .picks-note { color: var(--ink-soft); font-size: 0.95rem; }

  .pick-list {
    list-style: none;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  }

  .pick {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 0.6rem;
    padding: 1.15rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .pick-host { font-size: clamp(1.15rem, 5.4vw, 1.45rem); overflow-wrap: anywhere; }
  .pick-host a { color: var(--ink); text-decoration: none; }
  .pick-host a:hover { text-decoration: underline; }
  .pick-name { color: var(--ink-soft); font-size: 0.9rem; margin-top: -0.4rem; }
  .facts { list-style: none; color: var(--ink-soft); font-size: 0.95rem; }
  .reach { display: flex; align-items: center; gap: 0.7rem; font-size: 0.95rem; font-weight: 600; }
  .pick .button { margin-top: auto; }

  /* Herzschlag-Streifen: ein Strich pro Tag */
  .strip { width: 7.5rem; height: 0.95rem; flex: none; }
  .tick-up { fill: var(--up); }
  .tick-down { fill: var(--down); }
  .tick-none { fill: var(--none); }

  @keyframes sweep {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
  }
  @media (prefers-reduced-motion: no-preference) {
    .pick .strip { animation: sweep 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 80ms); }
  }

  /* Schaltflächen */
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.5rem 1.15rem;
    border: 2px solid var(--pine);
    border-radius: 0.5rem;
    background: var(--pine);
    color: var(--on-pine);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
  }
  .button:hover { background: var(--pine-strong); border-color: var(--pine-strong); }
  .button-quiet { background: transparent; color: var(--pine); min-height: 2.5rem; padding-inline: 0.9rem; }
  .button-quiet:hover { background: var(--pine); color: var(--on-pine); }

  /* Verzeichnis: Werkzeugleiste */
  .directory h2 { margin-bottom: 1.4rem; }

  .toolbar { display: grid; gap: 1rem 2rem; align-items: end; }
  .field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
  .field input[type="search"], .field input[type="text"], .field select {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.45rem 0.8rem;
    background: var(--surface);
    border: 2px solid var(--line-strong);
    border-radius: 0.5rem;
  }
  .check { display: inline-flex; align-items: center; gap: 0.7rem; min-height: 2.75rem; cursor: pointer; }
  .check input { width: 1.3rem; height: 1.3rem; accent-color: var(--pine); flex: none; }
  .count { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
  .field-sort { display: none; }

  @media (min-width: 48rem) {
    .toolbar { grid-template-columns: minmax(15rem, 24rem) auto 1fr; }
    .count { justify-self: end; padding-bottom: 0.6rem; }
  }
  @media (max-width: 47.99rem) {
    .field-sort { display: block; }
  }

  /* Verzeichnis: Tabelle */
  .pods-table { width: 100%; margin-top: 1.5rem; border-collapse: separate; border-spacing: 0; }
  .pods-table th, .pods-table td { padding: 0.85rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
  .pods-table thead th { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); vertical-align: bottom; padding-block: 0.6rem; }
  .pods-table .num { text-align: right; font-variant-numeric: tabular-nums; }
  .pods-table tbody tr:hover { background: color-mix(in srgb, var(--tint) 60%, transparent); }
  .pods-table th:first-child, .pods-table td:first-child { padding-left: 0; }
  .pods-table th:last-child, .pods-table td:last-child { padding-right: 0; text-align: right; }

  .sort {
    appearance: none;
    background: none;
    border: 0;
    padding: 0.3rem 0;
    font-weight: 600;
    text-align: inherit;
    color: inherit;
    cursor: pointer;
    border-bottom: 3px solid transparent;
  }
  .sort:hover { color: var(--ink); }
  .col-label { display: inline-block; padding: 0.3rem 0; border-bottom: 3px solid transparent; }
  th[aria-sort] .sort { color: var(--ink); border-bottom-color: var(--marigold); }
  th[aria-sort="ascending"] .sort::after { content: " \2191"; }
  th[aria-sort="descending"] .sort::after { content: " \2193"; }

  .pods-table td { white-space: nowrap; }
  .cell-pod { font-weight: 400; min-width: 13rem; }
  .pod-link { font-family: var(--font-display); font-size: 1.15rem; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
  .pod-link:hover { text-decoration: underline; }
  .tagline { display: block; font-size: 0.85rem; color: var(--ink-soft); }

  .reg { display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
  .reg::before { content: ""; width: 0.65rem; height: 0.65rem; border-radius: 50%; border: 2px solid var(--ink-soft); flex: none; }
  .reg-open { font-weight: 600; }
  .reg-open::before { background: var(--up); border-color: var(--up); }
  .reg-closed { color: var(--ink-soft); }

  .cell-reach { white-space: nowrap; }
  .cell-reach .strip { display: inline-block; vertical-align: middle; margin-right: 0.6rem; }
  .cell-reach .percent { font-variant-numeric: tabular-nums; display: inline-block; min-width: 3.4rem; }

  .empty { padding: 2.5rem 0; display: grid; gap: 0.75rem; justify-items: start; }
  .empty-note { color: var(--ink-soft); }

  /* Handy: aus der Tabelle wird eine Liste */
  @media (max-width: 47.99rem) {
    .pods-table, .pods-table tbody, .pods-table tr, .pods-table th, .pods-table td { display: block; }
    .pods-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .pods-table tbody tr {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.6rem 1rem;
      padding: 0.9rem 0;
      border-bottom: 1px solid var(--line);
    }
    .pods-table th, .pods-table td { padding: 0; border: 0; text-align: left; }
    .pods-table td { white-space: normal; }
    .pods-table .num, .pods-table th:last-child, .pods-table td:last-child { text-align: left; }
    .pods-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.8rem; color: var(--ink-soft); }
    .cell-pod { grid-column: 1 / -1; }
    /* Reihenfolge: Pod, Version, Anmeldung, Nutzer, Aktiv, Antwort, Anmelden, zuletzt der Streifen */
    .pods-table td:nth-child(7) { order: 5; }
    .cell-action { order: 6; justify-self: end; align-self: end; }
    .cell-reach { order: 10; grid-column: 1 / -1; }
    .cell-action:not(:has(a)) { display: none; }
    .fact-since { display: none; }
    .pick { padding: 1rem 1.1rem 1.1rem; gap: 0.6rem; }
  }

  /* Nicht antwortend */
  .fold { margin-top: 2.5rem; border-top: 1px solid var(--line); padding-top: 1.25rem; }
  .fold-title { font-size: 1rem; font-weight: 600; }
  .fold summary { font-weight: 600; cursor: pointer; padding-block: 0.3rem; }
  .fold p { margin-top: 0.75rem; color: var(--ink-soft); }
  .plain-list { list-style: none; margin-top: 0.75rem; display: grid; gap: 0.35rem; }
  .plain-list .host { font-weight: 600; margin-right: 0.75rem; }
  .muted { color: var(--ink-soft); font-size: 0.9rem; }

  /* So entsteht die Liste */
  .about p { margin-top: 0.9rem; }
  .about h3 { margin-bottom: 0.75rem; }
  .criteria { margin: 0 0 0.5rem; padding-left: 1.2rem; display: grid; gap: 0.4rem; }
  .criteria li::marker { color: var(--pine); }

  .site-footer p { max-width: none; }
  .footer-links { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
  .footer-links a { color: var(--ink-soft); }

  /* Textseiten (Impressum) */
  .prose { padding-block: clamp(2.5rem, 7vw, 4.5rem); }
  .prose h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); margin-bottom: 1.5rem; }
  .prose h2 { font-size: 1.4rem; margin: 2rem 0 0.5rem; }
  .prose p, .prose address { margin-top: 1rem; font-style: normal; }
  .prose .legal { color: var(--ink-soft); margin-top: 0; }
  .suggest-form { margin-top: 1.5rem; display: grid; gap: 1.25rem; max-width: 30rem; }
  .suggest-form .muted { margin-top: 0.35rem; }
  .suggest-form .button { justify-self: start; }
  .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
  .notice { margin-top: 1.25rem; padding: 0.9rem 1.1rem; border-radius: 0.5rem; border: 2px solid var(--line-strong); }
  .notice-ok { border-color: var(--pine); }
  .notice-error { border-color: var(--down); }
  .suggest-hint { margin-top: 1.25rem; color: var(--ink-soft); }
}

@layer utilities {
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
