/* Shared design tokens, reusable theme variables, reset, typography, buttons, and focus states */

:root {
    /* Reusable theme variables (ready for admin theme settings) */
    --theme-header-bg: #14532d;
    --theme-header-text: #ffffff;
    --theme-nav-link: rgba(255, 255, 255, 0.92);
    --theme-nav-link-hover: #ffffff;
    --theme-nav-active-bar: #ffffff;

    --theme-btn-primary-bg: #14532d;
    --theme-btn-primary-bg-hover: #114425;
    --theme-btn-primary-text: #ffffff;
    --theme-btn-header-bg: #ffffff;
    --theme-btn-header-text: #14532d;

    --theme-text-primary: #16211b;
    --theme-text-secondary: #46564d;
    --theme-text-muted: #5f6f66;
    --theme-link-color: #14532d;

    --theme-footer-bg: #14532d;
    --theme-footer-bottom-bg: rgba(0, 0, 0, 0.18);
    --theme-footer-text: #ffffff;
    --theme-footer-heading: #ffffff;
    --theme-footer-border: rgba(255, 255, 255, 0.18);
    --theme-footer-link-hover: #ffffff;
    --theme-footer-social: #ffffff;

    /* Structural surface and semantic aliases */
    --brand-primary: var(--theme-btn-primary-bg);
    --brand-primary-hover: var(--theme-btn-primary-bg-hover);
    --brand-accent: #166534;
    --brand-soft: #eef5f0;
    --brand-soft-border: #cfe0d5;

    --surface-page: #f7faf8;
    --surface-card: #ffffff;
    --surface-subtle: #f1f5f2;

    --ink-primary: var(--theme-text-primary);
    --ink-secondary: var(--theme-text-secondary);
    --ink-muted: var(--theme-text-muted);

    --border-hairline: #dbe3de;
    --border-strong: #c2cfc7;

    --danger-bg: #fef2f2;
    --danger-border: #f3c4c4;
    --danger-ink: #991b1b;

    --info-bg: #eef7f1;
    --info-border: #bed9c7;
    --info-ink: #14532d;

    --focus-ring: #15803d;
    --focus-ring-light: #ffffff;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --font-sans: "Plus Jakarta Sans", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --theme-font-heading: var(--font-sans);
    --theme-font-body: var(--font-sans);
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

    --container-max: 1240px;
    --header-height: 54px;
    --admin-header-height: 60px;
    --admin-sidebar-width: 256px;
    --ease-standard: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    margin: 0;
    font-family: var(--theme-font-body, var(--font-sans));
    font-size: 0.96875rem;
    line-height: 1.6;
    color: var(--ink-primary);
    background-color: var(--surface-page);
    overflow-x: clip;
}

h1,
h2,
h3,
h4 {
    font-family: var(--theme-font-heading, var(--font-sans));
}

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

img,
svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

[id] {
    scroll-margin-top: calc(var(--header-height) + 1rem);
}

/* Accessible keyboard focus indicators */
:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0.5rem;
    z-index: 100;
    padding: 0.625rem 1rem;
    background: var(--theme-header-bg);
    color: var(--theme-header-text);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.skip-link:focus {
    left: 0.75rem;
}

.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: 1rem;
}

@media (min-width: 640px) {
    .container {
        padding-inline: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .container {
        padding-inline: 1.5rem;
    }
}

/* Shared button system */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 42px;
    padding: 0.55rem 1.125rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 160ms var(--ease-standard),
                border-color 160ms var(--ease-standard),
                color 160ms var(--ease-standard);
}

.btn--sm {
    min-height: 36px;
    padding: 0.4rem 0.85rem;
    font-size: 0.84rem;
}

.btn--block {
    width: 100%;
}

.btn--primary {
    background-color: var(--theme-btn-primary-bg);
    color: var(--theme-btn-primary-text);
    border-color: var(--theme-btn-primary-bg);
}

.btn--primary:hover {
    background-color: var(--theme-btn-primary-bg-hover);
    border-color: var(--theme-btn-primary-bg-hover);
}

.btn--ghost {
    background-color: var(--surface-card);
    color: var(--theme-btn-primary-bg);
    border-color: var(--border-strong);
}

.btn--ghost:hover {
    background-color: var(--brand-soft);
    border-color: var(--theme-btn-primary-bg);
}

.btn--outline {
    background-color: transparent;
    color: var(--ink-primary);
    border-color: var(--border-strong);
}

.btn--outline:hover {
    background-color: var(--surface-subtle);
    border-color: var(--ink-secondary);
}

.btn--subtle {
    background-color: var(--surface-subtle);
    color: var(--ink-primary);
    border-color: var(--border-hairline);
}

.btn--subtle:hover {
    background-color: #e6ede9;
    border-color: var(--border-strong);
}

.text-link {
    color: var(--theme-link-color, var(--theme-btn-primary-bg));
    text-decoration: underline;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}

.text-link:hover {
    color: var(--theme-btn-primary-bg-hover);
}

/* Fallback 500 error page */
.fallback-error-body {
    padding: 2rem 1rem;
}

.fallback-error {
    max-width: 38rem;
    margin: 3rem auto;
    padding: 1.5rem;
    background: var(--surface-card);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-md);
}

.no-scroll {
    overflow: hidden;
}

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

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
