/* base.css — Structural layout only. Colors & fonts come from themes.css */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Core ── */
html {
    overflow-x: clip;
    transition: background-color 0.3s ease, color 0.3s ease;
}
body {
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    background-color: var(--background);
    color: var(--foreground);
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 { line-height: 1.25; overflow-wrap: break-word; }
h1 { font-size: clamp(1.75rem, 1.5rem + 1.1vw, 2.25rem); margin: 2.5rem 0 1.5rem; }
h1:first-child { margin-block-start: 0; }
h2 { font-size: clamp(1.5rem, 1.3rem + 0.8vw, 1.875rem); margin: 2rem 0 1.25rem; }
p { margin-block-end: 1rem; }
p:last-child { margin-block-end: 0; }
a { color: var(--primary); text-underline-offset: 2px; }
strong { font-weight: 600; }

/* ── Layout ── */
.container { max-width: 800px; margin-inline: auto; padding-inline: 2rem; }
.hstack { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.text-center { text-align: center; }
.text-light { opacity: 0.75; }

/* ── Main & Footer ── */
.main-content { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.site-footer { padding: 2rem 0; margin-top: 3.5rem; }
.footer-theme { margin-bottom: 1rem; }
#theme-select { width: auto; min-width: 7rem; }

/* ── Back link ── */
.back-link { margin-bottom: 0.5rem; font-size: 0.875rem; }
.back-link a { text-decoration: none; }
.back-link a:hover { text-decoration: underline; }

/* ── CTA card ── */
.cta-card {
    margin-bottom: 2rem;
}
.cta-link {
    display: block; padding: 1.25rem 1.5rem;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.cta-link .description {
    display: block; font-size: 0.875rem;
    color: var(--muted-foreground); margin-top: 0.25rem;
}

/* ── Table ── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem 0.5rem; text-align: start; }
th { font-weight: 500; }
.amount { text-align: right; font-variant-numeric: tabular-nums; }
.recipe-table:not(#rows-table) { table-layout: fixed; }
.recipe-table:not(#rows-table) th:nth-child(1) { width: 4.5rem; }
.recipe-table:not(#rows-table) th.amount { width: 5.5rem; }
.recipe-table:not(#rows-table) td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Buttons ── */
button, .button, a.button {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem; padding: 0.5rem 1rem; font-size: 0.875rem;
    font-weight: 500; line-height: 1.5; white-space: nowrap;
    text-decoration: none; cursor: pointer;
    background: var(--primary); color: var(--primary-foreground);
    border: 1px solid transparent;
    border-radius: var(--radius-medium, 0.375rem);
    transition: all 0.15s ease;
}
button:hover:not(:disabled), .button:hover:not(:disabled) { opacity: 0.85; }
.small { padding: 0.25rem 0.75rem; font-size: 0.75rem; }
.outline {
    background: transparent; color: var(--foreground);
    border-color: var(--border);
}
.outline:hover { background: var(--muted); opacity: 1; }

/* ── Forms ── */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
textarea, select {
    width: 100%; padding: 0.5rem 0.75rem; font-size: inherit;
    line-height: 1.5; background: var(--background); color: var(--foreground);
    border: 1px solid var(--input, var(--border));
    border-radius: var(--radius-medium, 0.375rem);
    margin-block-start: 0.25rem;
    transition: border-color 0.12s ease;
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--ring, var(--primary));
    outline-offset: 1px;
}
input::placeholder, textarea::placeholder { opacity: 0.5; }
textarea { min-height: 5rem; resize: vertical; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.5rem center;
    padding-inline-end: 1.5rem;
}
label { display: block; font-weight: 500; margin-bottom: 1rem; }
#rows-table input, #rows-table select { margin-block-start: 0; }
#rows-table .row-debet, #rows-table .row-kredit { width: 4.5rem; text-align: right; }
#rows-table td:last-child { width: 1px; white-space: nowrap; }
#link-output { margin: 1rem 0; }
.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-bottom: 1.5rem; }
.char-count { position: absolute; right: 0.5rem; bottom: 0.4rem; font-size: 0.6875rem; color: var(--muted-foreground); pointer-events: none; }
:disabled { opacity: 0.5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--ring, var(--primary)); outline-offset: 2px; }

/* ── Seed list ── */
.seed-list { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.seed-list li { padding: 0; transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease; }
.seed-list a { display: block; padding: 1rem 1.25rem; font-weight: 600; text-decoration: none; color: inherit; }
.seed-list a:hover { text-decoration: underline; }
.seed-list .description { display: block; font-size: 0.875rem; color: var(--muted-foreground); margin-top: 0.25rem; }

/* ── Recipe actions ── */
.recipe-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 2rem 0; }
.recipe-actions a { text-decoration: none; }

/* ── Nav ── */
.site-nav {
    padding: 0.75rem 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}
.site-brand {
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.site-brand-icon {
    width: 1.4em;
    height: 1.1em;
    flex-shrink: 0;
}
.nav-links {
    display: flex;
    gap: 1.5rem;
}
.nav-links a {
    text-decoration: none;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s ease;
}
.nav-links a:hover {
    color: var(--primary);
}

/* ── FAQ ── */
.faq-list {
    display: grid;
    gap: 0.75rem;
    scroll-margin-top: 2rem;
}
.faq-list details {
    scroll-margin-top: 2rem;
}
.faq-list details {
    padding: 1rem 1.25rem;
}
.faq-list summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.faq-list summary::-webkit-details-marker {
    display: none;
}
.faq-list summary::before {
    content: "+";
    display: inline-block;
    width: 1.5em;
    font-weight: 700;
    color: var(--primary);
}
.faq-list details[open] > summary::before {
    content: "\2212";
}
.faq-answer {
    margin-top: 1rem;
}
.faq-answer ul,
.faq-answer ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}
.faq-answer li {
    margin-bottom: 0.25rem;
}
.faq-answer table {
    margin: 1rem 0;
    table-layout: auto;
}
.faq-answer .recipe-table td:nth-child(2) {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}
.faq-answer .recipe-table th:nth-child(1) {
    width: auto;
}
.faq-answer .recipe-table th.amount {
    width: auto;
}

/* ── Editor help ── */
.editor-help { font-size: 0.875rem; color: var(--muted-foreground); margin-bottom: 1rem; }

/* ── Kontoplan ── */
#kp-search { margin-bottom: 1.5rem; }
.kp-details { margin-bottom: 2rem; }
.kp-details summary { cursor: pointer; font-weight: 600; font-size: 1.125rem; list-style: none; }
.kp-details summary::-webkit-details-marker { display: none; }
.kp-details summary::before { content: "+"; display: inline-block; width: 1.5em; font-weight: 700; color: var(--primary); }
.kp-details[open] > summary::before { content: "\2212"; }
.kp-cards { display: grid; gap: 0.75rem; margin-top: 0.75rem; }
.kp-card { padding: 0.75rem 1rem; }
.kp-card-num { font-variant-numeric: tabular-nums; font-weight: 700; }
.kp-card-name { margin-left: 0.5rem; }
.kp-card-recipes { display: block; font-size: 0.8125rem; color: var(--muted-foreground); margin-top: 0.25rem; }
.kp-card-recipes a { font-size: 0.8125rem; }
.kp-class { margin-bottom: 2rem; }
.kp-class h3 { font-size: 1.125rem; margin: 1rem 0 0.5rem; }
.kp-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.kp-table th, .kp-table td { padding: 0.375rem 0.5rem; text-align: start; font-size: 0.8125rem; border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; }
.kp-table th { font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted-foreground); }
.kp-num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; width: 4rem; }

/* ── Autocomplete dropdown ── */
.ac-dropdown {
    position: absolute;
    left: 0;
    top: 100%;
    width: max-content;
    max-width: calc(100vw - 2rem);
    z-index: 10;
    max-height: 14rem;
    overflow-y: auto;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-medium, 0.375rem);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.ac-item {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
}
.ac-item:hover, .ac-item.ac-active {
    background: var(--muted, #f0f0f0);
}
.ac-num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ── Utility ── */
[hidden] { display: none !important; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .container { padding-inline: 1rem; }
    .nav-links { gap: 1rem; }
    .nav-links a { font-size: 0.8125rem; }

    /* Tighter vertical rhythm on mobile */
    .main-content { padding-top: 1.25rem; padding-bottom: 1.5rem; }
    h1 { margin: 1.25rem 0 0.75rem; }
    h2 { margin: 1.25rem 0 0.625rem; }
    p { margin-block-end: 0.625rem; }
    label { margin-bottom: 0.625rem; }
    .recipe-actions { margin: 1rem 0; }
    .site-footer { margin-top: 2rem; padding: 1.25rem 0; }

    /* Recipe table: compact on mobile */
    .recipe-table th, .recipe-table td { padding: 0.375rem 0.375rem; font-size: 0.8125rem; }
    .recipe-table th { font-size: 0.75rem; }
    .recipe-table .amount { white-space: nowrap; }

    /* Editor: compact table on mobile — shrink Debet/Kredit, expand Konto */
    #rows-table th, #rows-table td { padding: 0.25rem 0.125rem; font-size: 0.75rem; }
    #rows-table th.amount, #rows-table td.amount { width: 4rem; }
    #rows-table th:last-child, #rows-table td:last-child { width: 1.75rem; }
    #rows-table input { font-size: 1rem; padding: 0.25rem 0.25rem; width: 100%; }
    #rows-table button { padding: 0.125rem 0.375rem; font-size: 0.75rem; min-width: 0; }

    /* Prevent iOS Safari auto-zoom on focus */
    select.small { font-size: 1rem; }
}
