/**
 * MAIN STYLESHEET
 * 
 * Structure:
 * 1. Import design tokens (auto-generated)
 * 2. Reset & Base styles
 * 3. Layout (header, footer, containers)
 * 4. Prose (shared content styling for markdown)
 * 5. Components (buttons, forms, tags, etc.)
 * 6. Responsive breakpoints
 */

@import 'fonts.css';
@import 'tokens.css';

/* ===========================================
   1. RESET & BASE STYLES
   =========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--color-text-primary);
    background-color: var(--color-bg-page);  /* Static background - change in brand.js */
    min-height: 100vh;
    overflow-x: hidden;  /* Prevent horizontal scroll from full-bleed elements */
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: normal;
    color: var(--color-text-primary);
}

a {
    color: var(--color-brand-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-button-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ===========================================
   2. LAYOUT
   =========================================== */

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 15px;
}

/* Header */
.header {
    background-color: var(--color-bg-header);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.1s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    min-height: 64px;
    gap: 1rem;
    position: relative;
}

.header-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -100vw;
    right: -100vw;
    height: 1px;
    background-color: var(--color-brand-dark);
}

/* Site Title / Logo */
.site-title {
    margin: 0;
}

.site-title a {
    font-size: var(--font-size-xl);
    font-weight: bold;
    text-decoration: none;
    font-family: var(--font-logo);
}

.logo-primary {
    font-weight: bold;
    font-size: 28px;
    color: var(--color-brand-dark);
}

.logo-secondary {
    font-weight: normal;
    font-family: var(--font-body);
    font-size: 28px;
    color: var(--color-brand-light);
}

.logo-separator {
    font-weight: bold;
    font-size: 28px;
    color: var(--color-brand-dark);
    margin: 0 0.1rem;
}

/* Center Logo */
.center-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.center-logo a {
    display: block;
    padding: 0.4rem 0.5rem;
    border-radius: var(--border-radius-small);
    transition: background-color 0.3s ease;
}

.center-logo a:hover {
    background-color: rgba(44, 62, 80, 0.1);
}

.center-logo img {
    display: block;
    width: 40px;
    height: 40px;
}

/* Header Icons (right side) */
.header-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-small);
    color: var(--color-text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 1.1rem;
    cursor: pointer;
    border: none;
    background: transparent;
}

.header-icon:hover {
    background-color: rgba(44, 62, 80, 0.1);
    color: var(--color-brand-dark);
}

.header-icon svg {
    width: 30px;
    height: 30px;
    stroke: currentColor;
    stroke-width: 1.25;
    fill: none;
}

/* Navigation */
.nav-section {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 400px;
    max-width: 90%;
    background-color: transparent;
    border-radius: var(--border-radius);
    text-align: center;
    overflow: hidden;
    z-index: 99;
    transition: max-height 0.5s ease, opacity 0.5s ease, padding 0.5s ease;
    max-height: 0;
    opacity: 0;
    padding: 0 1.5rem;
    pointer-events: none;
}

.nav-section.nav-open {
    max-height: 200px;
    opacity: 1;
    padding: 1rem 1.5rem;
    pointer-events: auto;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.nav-list li:not(:last-child)::after {
    content: "|";
    margin-left: 0.5rem;
    color: var(--color-text-primary);
    font-weight: bold;
}

.nav-link {
    color: var(--color-text-primary);
    text-decoration: none;
    font-weight: 300;
    padding: 0.4rem 1rem;
    border-radius: var(--border-radius);
    background-color: #e8e8e8;
    transition: background-color 0.2s ease;
}

.nav-link:hover {
    background-color: #d8d8d8;
}

.nav-link.active {
    color: var(--color-white);
    background-color: var(--color-brand-dark);
}

/* Footer */
.footer {
    background-color: var(--color-brand-dark);
    color: var(--color-white);
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h4 {
    margin-bottom: 1rem;
    color: var(--color-brand-light);
}

.footer-section p {
    opacity: 0.8;
    line-height: var(--line-height);
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--color-white);
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.footer-links a:hover {
    opacity: 1;
    color: var(--color-brand-light);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.7;
}

/* Footer logo - inverted colors */
.footer .logo-primary {
    color: var(--color-white);
}

.footer .logo-secondary {
    color: #cccccc;
}

.footer .logo-separator {
    color: var(--color-white);
}

/* ===========================================
   3. PROSE - Shared Content Styling
   =========================================== */

.prose {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
}

/* Headings */
.prose h1,
.prose h2,
.prose h3 {
    font-family: var(--font-heading);
    color: var(--color-text-primary);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: normal;
}

.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.8rem; }
.prose h3 { font-size: 1.4rem; }

/* Callout/quote box for h4 */
.prose h4 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 500;
    font-style: italic;
    color: var(--color-text-primary);
    background-color: rgba(170, 190, 209, 0.1);
    border-left: 4px solid var(--color-brand-light);
    padding: 1rem 2rem;
    margin: 2rem 1.5rem;
    border-radius: var(--border-radius-small);
    line-height: var(--line-height);
    text-align: center;
}

/* Paragraphs */
.prose p {
    margin-bottom: 1rem;
}

/* Lists */
.prose ul,
.prose ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.prose li {
    margin-bottom: 0.35rem;
}

/* Links */
.prose a {
    color: var(--color-button-bg);
    text-decoration: none;
    border-bottom: 1px solid var(--color-button-bg);
}

.prose a:hover {
    color: var(--color-button-hover);
    border-bottom-color: var(--color-button-hover);
}

/* Code */
.prose code {
    background: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.prose pre {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: var(--border-radius-small);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.prose pre code {
    background: none;
    padding: 0;
}

/* Blockquotes */
.prose blockquote {
    border-left: 4px solid var(--color-brand-dark);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Images - Default to container width */
.prose img {
    max-width: var(--container-max-width);
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 2rem 0;
    display: block;
}

/* Inline Image Display Modes */
.prose .img-mode--full-width {
    width: 100vw;
    max-width: 100vw;
    object-fit: cover;
    border-radius: 0;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

.prose .img-mode--container {
    width: var(--container-max-width);
    max-width: var(--container-max-width);
    /* Break out of the 700px reading container to reach 900px */
    margin-left: calc((var(--reading-max-width) - var(--container-max-width)) / 2);
    margin-right: calc((var(--reading-max-width) - var(--container-max-width)) / 2);
    display: block;
}

.prose .img-mode--text-width {
    max-width: var(--reading-max-width);
}

.prose .img-mode--text-plus {
    max-width: calc(var(--reading-max-width) * 1.1);
}

.prose .img-mode--natural {
    max-width: var(--container-max-width);
    object-fit: contain;
    width: auto;
}

/* ===========================================
   4. COMPONENTS
   =========================================== */

/* Post/Page Container */
.post-container,
.page-container {
    max-width: var(--reading-max-width);
    margin: 0 auto 2rem;
    background: transparent;
}

/* Header Image - Base styles */
.header-image {
    width: 100%;
    height: auto;
    margin-bottom: 1rem;
}

/* Full width mode - breaks out of container */
.header-image--full-width {
    width: 100vw;
    max-width: 100vw;
    object-fit: cover;
    max-height: 400px;
    border-radius: 0;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

/* Container mode - matches navbar content width (900px) */
.header-image--container {
    width: var(--container-max-width);
    max-width: var(--container-max-width);
    object-fit: cover;
    max-height: 400px;
    border-radius: var(--border-radius);
    /* Break out of the 700px reading container to reach 900px */
    margin-left: calc((var(--reading-max-width) - var(--container-max-width)) / 2);
    margin-right: calc((var(--reading-max-width) - var(--container-max-width)) / 2);
    display: block;
}

/* Text width mode - matches body */
.header-image--text-width {
    max-width: var(--reading-max-width);
    object-fit: cover;
    max-height: 400px;
    border-radius: var(--border-radius);
}

/* Text plus mode - 10% wider than text */
.header-image--text-plus {
    max-width: calc(var(--reading-max-width) * 1.1);
    object-fit: cover;
    max-height: 400px;
    border-radius: var(--border-radius);
}

/* Natural mode - no constraints */
.header-image--natural {
    max-width: var(--container-max-width);
    object-fit: contain;
    border-radius: var(--border-radius);
}

/* Post Header */
.post-header,
.page-header {
    margin-bottom: 1.5rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-brand-dark);
}

.post-title,
.page-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.2;
    font-weight: normal;
}

.post-description {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
    font-style: italic;
    line-height: 1.4;
}

/* Author Profile */
.post-author {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
}

.author-photo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-brand-dark);
    flex-shrink: 0;
}

.author-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.author-name {
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.post-date {
    font-style: italic;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.last-updated {
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.2;
    margin-bottom: 0;
}

/* Tags */
.post-tags,
.tag-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--color-bg-gradient-start);
    color: var(--color-text-primary);
    border-radius: var(--border-radius-small);
    font-size: 0.85rem;
    text-decoration: none;
}

.tag:hover {
    background: var(--color-bg-gradient-end);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--color-button-bg);
    color: var(--color-white);
    text-decoration: none;
    border-radius: var(--border-radius-small);
    border: none;
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: 400;
    transition: background 0.2s ease;
}

.btn:hover {
    background: var(--color-button-hover);
    color: var(--color-white);
}

.btn:disabled {
    background: var(--color-button-disabled);
    cursor: not-allowed;
}

.back-link {
    display: inline-block;
    margin-top: 3rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-button-bg);
    color: var(--color-white);
    text-decoration: none;
    border-radius: var(--border-radius-small);
    transition: background 0.2s ease;
}

.back-link:hover {
    background: var(--color-button-hover);
    color: var(--color-white);
}

/* Form Messages */
.form-message {
    padding: 1rem;
    border-radius: var(--border-radius-small);
    font-size: 0.85rem;
    margin-top: 1rem;
}

.form-message.success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.form-message.error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

/* ===========================================
   CTA BOX - Call to Action Component
   =========================================== */

.cta-box {
    width: 80%;
    margin: 2rem auto;
    padding: 1.5rem 2rem;
    background: var(--color-bg-cta);
    border-radius: 12px;
    text-align: center;
}

.cta-box h2,
.cta-box h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--color-text-primary);
    margin: 0 0 0.25rem 0;
    font-weight: normal;
}

.cta-box p {
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* CTA Subscribe Form */
.cta-form {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.cta-form input[type="email"] {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-small);
    min-width: 250px;
    font-family: var(--font-body);
}

.cta-form input[type="email"]:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.cta-form button {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    background: var(--color-button-bg);
    color: var(--color-white);
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font-body);
    transition: background 0.2s ease;
}

.cta-form button:hover {
    background: var(--color-button-hover);
}

.cta-consent {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.cta-consent label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* CTA Support State */
.cta-box--support .cta-btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--color-button-bg);
    color: var(--color-white);
    text-decoration: none;
    border-radius: var(--border-radius-small);
    font-weight: 500;
    transition: background 0.2s ease;
}

.cta-box--support .cta-btn:hover {
    background: var(--color-button-hover);
    color: var(--color-white);
}

/* CTA Thank You State */
.cta-box--thanks {
    padding: 1.5rem 2rem;
}

.cta-box--thanks h3 {
    margin-bottom: 0.25rem;
}

.cta-box--thanks p {
    margin-bottom: 0;
}

/* Hide inactive states (JS will toggle) */
.cta-state { display: none; }
.cta-state.active { display: block; }

/* ===========================================
   5. RESPONSIVE BREAKPOINTS
   =========================================== */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .nav-section {
        min-width: auto;
        width: 90%;
    }

    .nav-list {
        gap: 0.5rem;
    }

    .nav-link {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }

    .post-container,
    .page-container {
        margin: 0 1rem 1rem;
        padding: 1.5rem;
    }

    .post-title,
    .page-title {
        font-size: 2rem;
    }

    .prose {
        font-size: 1rem;
    }

    .prose h2 { font-size: 1.5rem; }
    .prose h3 { font-size: 1.2rem; }

    .container {
        padding: 0 10px;
    }

    /* CTA Box responsive */
    .cta-box {
        width: 90%;
        padding: 1.25rem 1.5rem;
    }

    .cta-form {
        flex-direction: column;
        align-items: center;
    }

    .cta-form input[type="email"] {
        width: 100%;
        min-width: auto;
    }

    .cta-form button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .logo-primary,
    .logo-secondary,
    .logo-separator {
        font-size: 22px;
    }

    .post-title,
    .page-title {
        font-size: 1.75rem;
    }
}

