/* ===== Design-Tokens ===== */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #5f6672;
  --border: #e2e5ea;
  --accent: #d6451b;
  --accent-contrast: #ffffff;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2b2f37;
    --accent: #ff6a3d;
    --accent-contrast: #111317;
    --ok: #4cc47f;
    --warn: #e0a84a;
    --shadow: none;
  }
}

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

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

main {
  flex: 1;
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5em;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ===== Header ===== */
#site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

#site-header .container {
  max-width: 1240px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}

.logo {
  font-weight: 700;
  white-space: nowrap;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 4px;
}

.main-nav ul {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.main-nav a {
  display: block;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
  background: var(--bg);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.2rem;
  padding: 4px 10px;
  cursor: pointer;
}

@media (max-width: 1200px) {
  .nav-toggle {
    display: block;
  }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
  }
  .main-nav.open {
    display: block;
  }
  .main-nav ul {
    flex-direction: column;
  }
}

/* ===== Hero ===== */
.hero {
  padding: 56px 0 32px;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 60ch;
}

/* ===== Tool-Grid ===== */
.section {
  padding: 24px 0 56px;
  scroll-margin-top: 64px; /* Sprungmarken nicht unter dem festen Header verstecken */
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

a.tool-card:hover,
.link-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Linkkarten: Hauptlink über die ganze Karte, Zusatzlinks liegen darüber */
.link-card {
  position: relative;
}
.link-main {
  color: inherit;
  text-decoration: none;
}
.link-main::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.link-extra {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
}
.link-area {
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.link-section-title {
  margin: 28px 0 6px;
  font-size: 1.1rem;
}
.link-section-note {
  margin: 0 0 12px;
}

.tool-card.is-planned {
  opacity: 0.6;
}

.tool-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.tool-card h3 {
  font-size: 1.05rem;
  margin: 6px 0 4px;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.tool-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.75rem;
}

.tool-category {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge {
  padding: 1px 8px;
  border-radius: 99px;
  font-weight: 600;
  border: 1px solid currentColor;
}

.badge-ready {
  color: var(--ok);
}
.badge-beta {
  color: var(--warn);
}
.badge-planned {
  color: var(--muted);
}

/* ===== Tool-Seiten ===== */
.tool-page {
  padding: 40px 0 56px;
}

.breadcrumb {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-top: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 500;
}

input,
select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.result {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}

.result-value {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
}

.placeholder {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

/* ===== Footer ===== */
#site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
}

.footer-inner {
  padding: 20px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.footer-inner p {
  margin: 0;
}

/* ===== Ergebnis-Tool ===== */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 24px;
  border-style: dashed;
  border-width: 2px;
  cursor: pointer;
  font-size: 1rem;
  text-align: center;
}

.dropzone.dragging {
  border-color: var(--accent);
}

.table-card {
  padding: 0;
  overflow-x: auto;
}

.result-table,
.stage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.result-table th,
.result-table td,
.stage-table th,
.stage-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.result-table th,
.stage-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.result-table .num,
.stage-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.result-row {
  cursor: pointer;
}

.result-row:hover,
.result-row.open {
  background: var(--bg);
}

.detail-row > td {
  padding: 0 0 12px 24px;
  background: var(--bg);
}

.stage-table td,
.stage-table th {
  padding: 4px 10px;
}

.warn {
  color: var(--warn);
}

details summary {
  cursor: pointer;
}

pre {
  overflow-x: auto;
  font-size: 0.8rem;
}

textarea {
  width: 100%;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  margin: 12px 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.button {
  font: inherit;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent);
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* ===== Regelverweise ===== */
.rule {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  vertical-align: 1px;
}

.notice {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--warn);
  color: var(--text);
  background: var(--surface);
  font-size: 0.92rem;
}

a.button {
  text-decoration: none;
  display: inline-block;
}

.result-table td.wrap {
  white-space: normal;
}

/* ===== Matchliste ===== */
.match-heading {
  margin-top: 32px;
  scroll-margin-top: 72px;
}
.matrix td a {
  font-weight: 600;
  text-decoration: none;
}
.matrix tfoot th {
  border-bottom: 0;
}
.month {
  margin: 24px 0 8px;
  font-size: 1rem;
  text-transform: capitalize;
}
.match-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.match-row:hover {
  border-color: var(--accent);
}
.match-date {
  flex: 0 0 5.5rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.match-level {
  flex: 0 0 auto;
  min-width: 2.6rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.match-level.lvl-2 {
  color: var(--ok);
  border-color: currentColor;
}
.match-level.lvl-3,
.match-level.lvl-4,
.match-level.lvl-5 {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}
.match-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.match-body .muted {
  font-size: 0.85rem;
}
@media (max-width: 520px) {
  .match-row {
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  .match-date {
    flex-basis: auto;
  }
  .match-body {
    flex-basis: 100%;
  }
}

/* ===== iPhone / App-Modus ===== */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  -webkit-tap-highlight-color: transparent;
}

/* Statusleiste ist transparent (black-translucent) – Inhalt um Notch/Dynamic Island herum */
#site-header {
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

main {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

#site-footer {
  padding-bottom: env(safe-area-inset-bottom);
}

/* iOS zoomt bei Eingabefeldern unter 16px automatisch hinein */
@media (max-width: 720px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
}
