/* Drop-in replacement for the BeerCSS classes we actually use.
   Re-implements: round, border, field, small, s6, s4, circle, max,
   center-align, right-align, chip, grid, active, badge, error, large,
   tabs, padding, toast, fixed, bottom.
   The rest of the visual system lives in style.css and overrides here when
   the project asks for tighter control (forms, modals, navs, etc.). */

/* ---------- Reset (minimal — BeerCSS' was opinionated, we keep ours light) ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { max-width: 100%; }

/* Heading defaults — BeerCSS shipped these and our style.css assumes a sane
   scale rather than the browser default (h6 at 0.67em, huge top margins). */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 8px;
    font-weight: 600;
    line-height: 1.25;
    color: inherit;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.95rem; font-weight: 500; }
p { margin: 0 0 8px; }

/* ---------- Geometry ---------- */
.round { border-radius: 18px; }
.circle { border-radius: 50%; }

/* ---------- Borders / surfaces ---------- */
.border {
    border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
    background: transparent;
}
[data-theme="dark"] .border { border-color: var(--border, rgba(255, 255, 255, 0.14)); }

/* ---------- Sizing ---------- */
.max { width: 100%; }
.large { font-size: 1.25rem; }
.small { font-size: 0.875rem; }

/* ---------- Alignment ---------- */
.center-align { text-align: center; }
.right-align { text-align: right; }

/* ---------- Spacing ---------- */
.padding { padding: 16px; }

/* ---------- Row (flex utility) ----------
   BeerCSS' .row is a horizontal flex container with sensible alignment defaults. */
.row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- Layout: 12-col grid (mobile-first, .s* spans) ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}
.grid > * { grid-column: span 12; }
.s4 { grid-column: span 4; }
.s6 { grid-column: span 6; }
@media (max-width: 600px) {
    /* On narrow screens BeerCSS collapses columns; mirror that for s6 too. */
    .s6, .s4 { grid-column: span 12; }
}

/* ---------- Field (input wrapper) ----------
   .field is a relative container. When combined with .round.border it
   draws the outline and the input fills it. */
.field {
    position: relative;
    display: block;
    margin: 8px 0;
    padding: 12px 14px;
    background: var(--surface, transparent);
    transition: border-color 120ms;
}
.field.round { border-radius: 18px; }
.field > label,
.field > .helper {
    display: block;
    font-size: 12px;
    color: var(--muted-fg, #666);
    margin-bottom: 4px;
}
.field > input,
.field > select,
.field > textarea {
    width: 100%;
    background: transparent;
    border: 0;
    outline: none;
    padding: 4px 0;
    color: var(--text);
}
.field > input::placeholder,
.field > textarea::placeholder { color: var(--muted-fg, #999); }
.field:focus-within { border-color: var(--primary); }
.field.error { border-color: var(--error, #d32f2f); }
.field.error > .helper { color: var(--error, #d32f2f); }

/* ---------- Chip ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent, rgba(0, 0, 0, 0.06));
    color: var(--text);
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: background 120ms;
    border: 1px solid transparent;
}
.chip:hover { background: var(--accent-hover, rgba(0, 0, 0, 0.1)); }
.chip.active,
.chip.primary {
    background: var(--primary);
    color: var(--on-primary, #fff);
}
.chip.small { padding: 4px 8px; font-size: 12px; }

/* ---------- Badge ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary);
    color: var(--on-primary, #fff);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}
.badge:empty { display: none; }

/* ---------- Tabs (used inside .sub-nav.tabs) ---------- */
.tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tabs > * {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    color: var(--muted-fg, #666);
    background: transparent;
    border: 0;
    white-space: nowrap;
}
.tabs > .active {
    background: var(--primary);
    color: var(--on-primary, #fff);
}

/* Toast styling lives in style.css (project owns the placement + animation).
   No duplicate rule here to avoid cascade conflicts. */

/* ---------- Position helpers ---------- */
.fixed { position: fixed; }
.bottom { bottom: 0; }

/* ---------- App bar / header ----------
   BeerCSS rendered <header class="fixed"> as a top app bar with full-width
   positioning, padding, and a flex inner-nav. We reproduce just enough so the
   topbar sits cleanly under the WIP banner and lays its inner nav out as a
   horizontal flex row. The forest-green background is in style.css. */
header {
    display: block;
    padding: 0 16px;
    min-height: var(--topbar-height, 64px);
}
header.fixed,
body > header.fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    width: 100%;
    box-sizing: border-box;
}
/* Inner <nav> inside the header: horizontal flex of brand / title / actions */
header > nav,
header nav[aria-label] {
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--topbar-height, 64px);
}

/* Bottom nav (mobile) — laid out as 5 equal-flex columns of icon + label */
nav.bottom {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: var(--nav-height, 64px);
}
nav.bottom > .nav-item,
nav.bottom > a {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    color: var(--muted-fg, #666);
    text-decoration: none;
    font-size: 11px;
    line-height: 1.1;
    text-align: center;
    transition: color 120ms;
}
nav.bottom > .nav-item.active,
nav.bottom > .nav-item[aria-selected="true"] {
    color: var(--primary);
    font-weight: 600;
}
nav.bottom > .nav-item i { font-size: 22px; line-height: 1; }

/* ---------- Buttons ----------
   BeerCSS gave every <button class="round"> a padded primary surface and
   variants (.border outlined, .transparent text-only, .circle icon, .small/
   .large size modifiers, .max full-width, .error destructive). We re-create
   only the variants the app uses — `.btn`, `.nav-item`, `.sub-nav-item`,
   `.desktop-nav-item` etc. keep their own styles from style.css. */

/* Primary filled — default for `button.round` */
button.round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--primary);
    color: var(--on-primary, var(--primary-fg, #fff));
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    transition: background 120ms, transform 80ms, box-shadow 120ms, opacity 120ms;
    white-space: nowrap;
}
button.round:hover { filter: brightness(1.05); }
button.round:active { transform: translateY(1px); }
button.round:disabled { opacity: 0.5; cursor: not-allowed; }
button.round:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Outlined */
button.round.border,
button.border {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
}
button.round.border:hover,
button.border:hover { background: var(--accent, rgba(0, 0, 0, 0.04)); }

/* Text-only */
button.transparent {
    background: transparent;
    color: var(--text);
    border: 0;
}
button.transparent:hover { background: var(--accent, rgba(0, 0, 0, 0.06)); }
.transparent { background: transparent; }

/* Destructive */
button.round.error {
    background: var(--error, #d32f2f);
    color: #fff;
    border-color: transparent;
}
button.round.error.border {
    background: transparent;
    color: var(--error, #d32f2f);
    border-color: var(--error, #d32f2f);
}

/* Size modifiers */
button.round.small,
button.small {
    padding: 6px 12px;
    min-height: 30px;
    font-size: 0.85rem;
}
button.round.large,
button.large {
    padding: 12px 24px;
    min-height: 46px;
    font-size: 1.05rem;
}

/* Full-width */
button.max,
.max { width: 100%; }
button.max { width: 100%; max-width: 100%; }

/* Icon-only round button (no padding text) */
button.circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background 120ms;
}
button.circle:hover { background: rgba(125, 125, 125, 0.18); }
button.circle.transparent { background: transparent; }
button.circle.transparent:hover { background: rgba(255, 255, 255, 0.10); }
button.circle.small { width: 32px; height: 32px; min-width: 32px; }

/* Inner <i> icon spacing for buttons that combine icon + text */
button.round > i,
button.border > i { font-size: 18px; }
button.round.small > i { font-size: 16px; }

/* ---------- Error colour utility ---------- */
.error { color: var(--error, #d32f2f); }
.field.error,
.border.error { border-color: var(--error, #d32f2f); }

/* ---------- Material Symbols leftover override (we use Lucide now) ----------
   BeerCSS injected an <i> font-family declaration; without BeerCSS some legacy
   <i> wrappers default to italic. Reset that and let Lucide take over. */
i { font-style: normal; }
