/* base.css — tokens, reset, typography, animations, header/footer, global components (buttons, forms, flash, badges), utilities, toasts. Loads first. */

/* The Daily Permit - Dark Editorial Design System */
/* A premium gazette aesthetic with warmth and character */

/* === FONTS === */
/* Fonts loaded via <link> in HTML head for faster loading */

/* === CUSTOM PROPERTIES === */
:root {
    /* Colors - Dark Editorial Palette */
    --bg-ink: #0d0c0b;
    --bg-paper: #1a1918;
    --bg-elevated: #242220;
    --bg-hover: #2e2c29;

    /* Accent Colors - Warm & Distinctive */
    --accent-terracotta: #c17f59;
    --accent-terracotta-light: #d4956f;
    --accent-terracotta-dark: #a66b48;
    --accent-gold: #d4a84b;
    --accent-gold-light: #e4be6a;
    --accent-sage: #7d9a7d;

    /* Semantic Colors */
    --color-success: #7d9a7d;
    --color-warning: #d4a84b;
    --color-error: #c75b5b;
    --color-info: #7b9eb8;

    /* Text Colors - Warm Cream Tones */
    --text-primary: #f5f0e8;
    --text-body: #c9c4bc;
    --text-muted: #8a8580;
    --text-faint: #5a5754;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-accent: var(--accent-terracotta);

    /* Sizing */
    --max-width: 1200px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows - Subtle & Warm */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(193, 127, 89, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-smooth: 300ms ease;
    --transition-slow: 500ms ease;

    /* Typography families (loaded in base.html). These tokens are referenced
       across landing/dashboard/admin/auth CSS; without them those
       `font-family: var(--font-*)` rules resolved to nothing and silently fell
       back to the inherited body serif. */
    --font-headline: 'Playfair Display', Georgia, serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Crimson Pro', Georgia, serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', ui-monospace, monospace;
}

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-body);
    background-color: var(--bg-ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.015;
    pointer-events: none;
    z-index: 0;
}

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 {
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.375rem;
    margin-bottom: 0.75rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-body);
}

a {
    color: var(--accent-terracotta);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-terracotta-light);
}

strong {
    font-weight: 600;
    color: var(--text-primary);
}

ul, ol {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
    color: var(--text-body);
}

/* Monospace for permit numbers & technical content */
.mono, code {
    font-family: 'IBM Plex Mono', 'SF Mono', monospace;
    font-size: 0.9em;
}

/* Lead text */
.lead {
    font-size: 1.25rem;
    color: var(--text-body);
    line-height: 1.6;
}

/* === ORNAMENTAL ELEMENTS === */
.ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    color: var(--text-faint);
}

.ornament::before,
.ornament::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-medium), transparent);
}

.ornament-symbol {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
}

/* Corner marks for cards */
.corner-mark {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--accent-terracotta);
    border-style: solid;
    opacity: 0.4;
    transition: opacity var(--transition-smooth);
}

.corner-mark-tl {
    top: -1px;
    left: -1px;
    border-width: 2px 0 0 2px;
}

.corner-mark-tr {
    top: -1px;
    right: -1px;
    border-width: 2px 2px 0 0;
}

.corner-mark-bl {
    bottom: -1px;
    left: -1px;
    border-width: 0 0 2px 2px;
}

.corner-mark-br {
    bottom: -1px;
    right: -1px;
    border-width: 0 2px 2px 0;
}

/* === ANIMATIONS === */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes drawLine {
    from { stroke-dashoffset: 1000; }
    to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
    from {
        stroke-dasharray: 100;
        stroke-dashoffset: 100;
    }
    to {
        stroke-dasharray: 100;
        stroke-dashoffset: 0;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100px) rotate(720deg);
    }
}

@keyframes circleDraw {
    from {
        stroke-dasharray: 300;
        stroke-dashoffset: 300;
    }
    to {
        stroke-dasharray: 300;
        stroke-dashoffset: 0;
    }
}

.animate-in {
    animation: fadeUp 0.6s ease-out forwards;
    opacity: 0;
}

.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hero-text,
    .hero-text h1 .word,
    .hero-text p,
    .hero-cta,
    .hero-social-proof,
    .hero-illustration svg.hero-building {
        opacity: 1 !important;
        transform: none !important;
    }

    .hero-text h1::after {
        width: 100px !important;
    }

    .hero-shapes {
        display: none;
    }

    /* SVG elements should be visible immediately */
    .hero-building .draw-path,
    .hero-building .window,
    .hero-building .bird,
    .hero-building .bg-building,
    .hero-building .measurement-text {
        opacity: 1 !important;
        stroke-dashoffset: 0 !important;
    }

    .hero-building .window {
        fill: rgba(212, 168, 75, 0.3) !important;
    }

    .features-bento > * {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* SVG Animations */
.draw-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 1.5s ease-out forwards;
}

.draw-check {
    animation: drawCheck 0.5s ease-out 0.3s forwards;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}

.circle-draw {
    animation: circleDraw 0.6s ease-out forwards;
}

.pulse-badge {
    animation: pulse 2s infinite;
}

.confetti-piece {
    animation: confettiFall 1.5s ease-out var(--delay, 0s) forwards;
}

/* === HEADER === */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 12, 11, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 0;
}

header nav {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .logo {
    display: flex;
    align-items: center;
}

header .logo-img {
    height: 60px;
    width: auto;
    transition: opacity var(--transition-fast);
}

header .logo:hover .logo-img {
    opacity: 0.85;
}

header ul {
    list-style: none;
    display: flex;
    /* Center items on a shared baseline so the logout <button>/<form> (a block
       that fills its <li>) lines up with the inline <a> links, which otherwise
       top-align in the stretched flex item. */
    align-items: center;
    gap: 2.5rem;
    margin: 0;
}

header li {
    margin: 0;
}

header nav a {
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.5rem 0;
    position: relative;
    transition: color var(--transition-fast);
    letter-spacing: 0.02em;
}

header nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent-terracotta);
    transition: width var(--transition-smooth);
}

header nav a:hover {
    color: var(--text-primary);
}

header nav a:hover::after {
    width: 100%;
}

/* Logout is a CSRF-protected POST form; style its button to read as a link. */
.nav-logout-form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}

.nav-logout-button {
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
    font-weight: 500;
    line-height: inherit;
    color: var(--text-muted);
    padding: 0.5rem 0;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast);
    letter-spacing: 0.02em;
}

.nav-logout-button:hover {
    color: var(--text-primary);
}

header nav .nav-logout-button::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent-terracotta);
    transition: width var(--transition-smooth);
}

header nav .nav-logout-button:hover::after {
    width: 100%;
}

header .logo:hover {
    color: var(--text-primary);
}

header .logo:hover::after {
    display: none;
}

/* === MAIN CONTENT === */
main {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem;
    min-height: calc(100vh - 200px);
}

/* Top-level page sections get breathing room. Scoped to `main > section`
   so nested sections (e.g. .report-card inside .research-report) aren't
   affected by this default. See the CSS follow-up note in CLAUDE.md about
   eventually removing this rule in favor of explicit per-component margins. */
main > section {
    margin-bottom: 4rem;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-sm);
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--transition-smooth);
    position: relative;
    letter-spacing: 0.02em;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent-terracotta);
    color: var(--bg-ink);
    box-shadow: 0 4px 12px rgba(193, 127, 89, 0.3);
}

.btn-primary:hover {
    background: var(--accent-terracotta-light);
    box-shadow: 0 6px 16px rgba(193, 127, 89, 0.4);
    color: var(--bg-ink);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-terracotta);
    color: var(--text-primary);
}

.btn-success {
    background: var(--color-success);
    color: var(--bg-ink);
    box-shadow: 0 4px 12px rgba(125, 154, 125, 0.3);
}

.btn-success:hover {
    background: #8fae8f;
    box-shadow: 0 6px 16px rgba(125, 154, 125, 0.4);
    color: var(--bg-ink);
}

.btn-danger {
    background: var(--color-error);
    color: white;
    box-shadow: 0 4px 12px rgba(199, 91, 91, 0.3);
}

.btn-danger:hover {
    background: #d46c6c;
    box-shadow: 0 6px 16px rgba(199, 91, 91, 0.4);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-body);
    padding: 0.5rem 1rem;
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    transform: none;
}

.btn-warning {
    background: var(--accent-gold);
    color: var(--bg-ink);
    box-shadow: 0 4px 12px rgba(212, 168, 75, 0.3);
}

.btn-warning:hover {
    background: var(--accent-gold-light);
    box-shadow: 0 6px 16px rgba(212, 168, 75, 0.4);
    color: var(--bg-ink);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-large {
    padding: 1rem 2.25rem;
    font-size: 1.0625rem;
}

/* Button loading state */
.btn.loading {
    color: transparent !important;
    pointer-events: none;
    position: relative;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spinner 0.8s linear infinite;
}

.btn-primary.loading::after {
    border-color: var(--bg-ink);
    border-top-color: transparent;
}

.btn-secondary.loading::after {
    border-color: var(--text-primary);
    border-top-color: transparent;
}

@keyframes btn-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Button with icon */
.btn .icon {
    width: 18px;
    height: 18px;
}

/* === FOOTER === */
footer {
    position: relative;
    z-index: 1;
    background: var(--bg-paper);
    border-top: 1px solid var(--border-subtle);
    padding: 2.5rem 2rem;
    margin-top: auto;
}

footer p {
    max-width: var(--max-width);
    margin: 0 auto;
    text-align: center;
    font-size: 0.9375rem;
    color: var(--text-muted);
}

.footer-links {
    margin-top: 0.75rem !important;
    font-size: 0.8125rem !important;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent-terracotta);
}

/* === FLASH MESSAGES === */
.flash-messages {
    margin-bottom: 2rem;
}

.flash {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    border: 1px solid;
    animation: slideInLeft 0.4s ease-out;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.flash::before {
    font-size: 1.25rem;
}

.flash-success {
    background: rgba(125, 154, 125, 0.15);
    border-color: rgba(125, 154, 125, 0.4);
    color: var(--color-success);
}

.flash-success::before {
    content: '\2713';
}

.flash-error {
    background: rgba(199, 91, 91, 0.15);
    border-color: rgba(199, 91, 91, 0.4);
    color: var(--color-error);
}

.flash-error::before {
    content: '\2717';
}

.flash-warning {
    background: rgba(212, 168, 75, 0.15);
    border-color: rgba(212, 168, 75, 0.4);
    color: var(--color-warning);
}

.flash-warning::before {
    content: '\26A0';
}

.flash-info {
    background: rgba(123, 158, 184, 0.15);
    border-color: rgba(123, 158, 184, 0.4);
    color: var(--color-info);
}

.flash-info::before {
    content: '\2139';
}

/* === FORMS === */
fieldset {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 2rem;
    margin-bottom: 2rem;
    background: var(--bg-paper);
}

legend {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    padding: 0 1rem;
    color: var(--text-primary);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-ink);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    transition: all var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-terracotta);
    box-shadow: 0 0 0 3px rgba(193, 127, 89, 0.15);
}

input[type="checkbox"],
input[type="radio"] {
    margin-right: 0.5rem;
    accent-color: var(--accent-terracotta);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    margin-bottom: 0;
}

.form-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-style: italic;
}

/* === STATUS BADGES === */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: 'Crimson Pro', serif;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-badge-large {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.status-active, .status-completed, .status-healthy, .status-closed, .status-sent {
    background: rgba(125, 154, 125, 0.2);
    color: var(--color-success);
}

.status-pending, .status-in-progress, .status-processing, .status-trialing {
    background: rgba(123, 158, 184, 0.2);
    color: var(--color-info);
}

.status-partial, .status-warning, .status-paused, .status-retrying {
    background: rgba(212, 168, 75, 0.2);
    color: var(--color-warning);
}

.status-failed, .status-error, .status-bounced, .status-canceled, .status-payment-failed {
    background: rgba(199, 91, 91, 0.2);
    color: var(--color-error);
}

.status-unsubscribed, .status-inactive, .status-pending-payment {
    background: rgba(138, 133, 128, 0.2);
    color: var(--text-muted);
}

/* === UTILITIES === */

.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;
}

/* ==========================================================================
   Admin shared: toast notifications (admin/base.html)
   Shared across every admin page via admin/base.html — intentionally global.
   .btn.loading is already defined earlier in this file (using btn-spinner),
   so we don't redefine it here.
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toastSlideIn 0.3s ease-out;
    max-width: 400px;
}

.toast-success { border-left: 3px solid #68d391; }
.toast-error { border-left: 3px solid #fc8181; }
.toast-warning { border-left: 3px solid #f6ad55; }
.toast-info { border-left: 3px solid #63b3ed; }

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover { color: var(--text-primary); }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


/* Responsive rules for this file, distributed from the pre-split combined @media block */
@media (max-width: 768px) {
    header nav {
        flex-direction: column;
        gap: 1rem;
    }

    header ul {
        gap: 1.5rem;
    }

    main {
        padding: 2rem 1rem;
    }

}
