/*
 * SubstackToKindle - Minimalistic Design System
 * Inspired by modern, clean interfaces with focus on typography and whitespace
 */

:root {
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;

    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #666666;
    --color-text-light: #999999;
    --color-border: #e5e5e5;
    --color-accent: #ef4444;
    --color-accent-light: #fef2f2;
    --color-accent-dark: #dc2626;
    --color-black: #000000;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 48px;
    --spacing-xl: 72px;
    --spacing-xxl: 120px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: var(--spacing-sm);
}

h1 {
    font-size: 48px;
    font-weight: 600;
    letter-spacing: -0.03em;
}

h2 {
    font-size: 36px;
}

h3 {
    font-size: 24px;
}

h4 {
    font-size: 18px;
}

p {
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-muted);
}

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

a:hover {
    opacity: 0.7;
}

/* Layout */
.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.container-narrow {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* Navigation */
nav {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-sm) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.9);
}

nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav .logo {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

nav ul {
    list-style: none;
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

nav ul li a {
    font-size: 14px;
    color: var(--color-text-muted);
}

nav ul li a:hover {
    color: var(--color-text);
}

/* Hero Section */
.hero {
    padding: var(--spacing-xxl) 0 var(--spacing-xl) 0;
    text-align: center;
}

.hero h1 {
    font-size: 72px;
    margin-bottom: var(--spacing-md);
    line-height: 1.1;
    color: var(--color-text);
}

.hero p {
    font-size: 20px;
    color: var(--color-text-muted);
    max-width: 650px;
    margin: 0 auto var(--spacing-lg) auto;
    line-height: 1.5;
}

/* Buttons */
button, .button, input[type="submit"] {
    background: var(--color-accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-primary);
}

button:hover, .button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    opacity: 0.9;
}

button.secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

button.secondary:hover {
    border-color: var(--color-accent);
}

/* Cards */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
}

.card-header h3 {
    margin-bottom: 4px;
}

/* Grid cards should have equal heights */
.grid .card {
    height: 100%;
}

/* Forms */
input, textarea, select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--spacing-xs);
    font-size: 14px;
    font-family: var(--font-primary);
    background: var(--color-surface);
    transition: all 0.2s ease;
}

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

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-help {
    font-size: 12px;
    color: var(--color-text-light);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: #dc3545;
    margin-top: 4px;
}

/* Code blocks */
code {
    background: #f5f5f5;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--color-accent);
    border: 1px solid var(--color-border);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

thead {
    background: #fafafa;
    border-bottom: 1px solid var(--color-border);
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: #fafafa;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-received {
    background: #f5f5f5;
    color: #666;
}

.status-processing {
    background: #e3f2fd;
    color: #1976d2;
}

.status-ready {
    background: #e8f5e9;
    color: #388e3c;
}

.status-delivered {
    background: #f3e5f5;
    color: #7b1fa2;
}

.status-failed {
    background: #ffebee;
    color: #c62828;
}

/* Messages */
.message {
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    border-left: 3px solid;
}

.message-success {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #166534;
}

.message-error {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.message-info {
    background: #f0f9ff;
    border-color: #3b82f6;
    color: #1e40af;
}

.message-warning {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

/* Grid */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-auto-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-auto-3 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (max-width: 768px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Features Section */
.features {
    padding: var(--spacing-xl) 0;
}

.feature {
    text-align: center;
}

.feature-icon {
    font-size: 32px;
    margin-bottom: var(--spacing-sm);
}

.feature h3 {
    margin-bottom: 8px;
}

.feature p {
    font-size: 14px;
}

/* Dashboard specific */
.dashboard-header {
    padding: var(--spacing-lg) 0 var(--spacing-md) 0;
}

.dashboard-header h1 {
    font-size: 42px;
    margin-bottom: 8px;
}

.dashboard-header p {
    font-size: 16px;
}

.inbox-display {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.inbox-email {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--color-accent);
    background: #f5f5f5;
    padding: 8px 12px;
    border-radius: 6px;
}

.copy-button {
    background: var(--color-accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    transform: translateY(-1px);
}

/* Auth pages */
.auth-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-box {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    border: 1px solid var(--color-border);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.auth-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.auth-header p {
    font-size: 14px;
}

.auth-footer {
    text-align: center;
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

.auth-footer a {
    font-size: 14px;
    color: var(--color-text-muted);
}

/* Info boxes */
.info-box {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.info-box ul {
    list-style: none;
    margin-top: 12px;
}

.info-box li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--color-text-muted);
}

.info-box li::before {
    content: "→";
    margin-right: 8px;
    color: var(--color-text-light);
}

/* HTMX indicators */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

/* Problem-Solution Sections */
.problem-section {
    background: var(--color-accent-light);
    padding: 96px 0;
    border-left: 4px solid var(--color-accent);
}

.solution-section {
    padding: 96px 0;
}

.accent-box {
    background: var(--color-accent);
    color: white;
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
}

.accent-box h2, .accent-box h3, .accent-box p {
    color: white;
}

/* Visual Elements */
.icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-sm) auto;
    font-size: 28px;
    font-weight: 600;
}

.icon-circle.accent {
    background: var(--color-accent);
    color: white;
}

.icon-circle.light {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) 0;
    flex-wrap: wrap;
}

.diagram-step {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.diagram-arrow {
    font-size: 24px;
    color: var(--color-accent);
}

.visual-block {
    background: linear-gradient(135deg, var(--color-accent-light) 0%, var(--color-surface) 100%);
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
}

/* Highlighted Text */
.highlight {
    background: var(--color-accent);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
}

.underline-accent {
    border-bottom: 3px solid var(--color-accent);
    padding-bottom: 2px;
}

/* Call to Action Sections */
.cta-section {
    background: var(--color-black);
    color: white;
    padding: var(--spacing-xxl) 0;
    text-align: center;
}

.cta-section h2, .cta-section p {
    color: white;
}

.cta-section button {
    background: var(--color-accent);
    font-size: 16px;
    padding: 16px 32px;
}

.cta-section button:hover {
    background: var(--color-accent-dark);
}

/* Stats/Numbers */
.stat {
    text-align: center;
}

.stat-number {
    font-size: 48px;
    font-weight: 600;
    color: var(--color-accent);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Comparison Table */
.comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.comparison-before {
    padding: var(--spacing-md);
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: var(--radius-md);
}

.comparison-after {
    padding: var(--spacing-md);
    background: var(--color-accent-light);
    border-left: 4px solid var(--color-accent);
    border-radius: var(--radius-md);
}

/* Accent Decorations */
.accent-dot {
    width: 12px;
    height: 12px;
    background: var(--color-accent);
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-accent);
    margin-bottom: var(--spacing-sm);
}

/* Utility classes */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-light { color: var(--color-text-light); }
.text-accent { color: var(--color-accent); }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

/* 3D Rotating Word Animation - Cylinder Effect */
.word-rotate {
    display: inline-block;
    position: relative;
    height: 1.2em;
    overflow: hidden;
    vertical-align: bottom;
    perspective: 600px;
    min-width: 200px;
    text-align: left;
}

.word-rotate-inner {
    display: inline-block;
    position: relative;
    transform-style: preserve-3d;
}

.word-rotate-item {
    display: inline-block;
    height: 1.2em;
    line-height: 1.2em;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-origin: center center;
    will-change: transform, opacity;
}

.word-rotate-item:not(:first-child) {
    position: absolute;
    top: 0;
    left: 0;
}

/* Accent color for rotating words */
.hero .word-rotate {
    color: var(--color-accent);
    font-weight: 600;
}

.hero h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.3em;
}

/* Responsive */
@media (max-width: 768px) {
    .container, .container-narrow {
        padding: 0 var(--spacing-md);
    }

    .hero {
        padding: 72px 0 48px 0;
    }

    .hero h1 {
        font-size: 48px;
    }

    .hero p {
        font-size: 18px;
    }

    nav ul {
        gap: var(--spacing-sm);
    }

    .auth-box {
        padding: var(--spacing-md);
    }

    h1 {
        font-size: 42px;
    }

    h2 {
        font-size: 32px;
    }

    .problem-section, .solution-section {
        padding: 64px 0;
    }

    .comparison {
        grid-template-columns: 1fr;
    }

    .diagram {
        flex-direction: column;
    }

    .diagram-arrow {
        transform: rotate(90deg);
    }

    .word-rotate {
        min-width: 150px;
    }
}
