/* ===========================================
   Design System - Refined Dark Luxury
   duncant.co.uk
   =========================================== */

/* ===========================================
   1. CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   =========================================== */

:root {
    /* Typography */
    --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-sans: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'DM Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace;
    
    /* Colors - Backgrounds */
    --bg-deep: #0a0a0b;
    --bg-elevated: #141416;
    --bg-card: #1a1a1c;
    --bg-card-hover: #222224;
    --bg-input: rgba(0, 0, 0, 0.3);
    
    /* Colors - Accent (Gold) */
    --accent: #c9a962;
    --accent-hover: #d4b46d;
    --accent-muted: #8b7640;
    --accent-dim: rgba(201, 169, 98, 0.15);
    --accent-glow: rgba(201, 169, 98, 0.25);
    
    /* Colors - Text */
    --text-primary: #f5f5f3;
    --text-secondary: #8a8a88;
    --text-muted: #5a5a58;
    --text-inverse: #0a0a0b;
    
    /* Colors - Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(201, 169, 98, 0.3);
    
    /* Colors - Status */
    --success: #4ade80;
    --success-dim: rgba(74, 222, 128, 0.15);
    --warning: #fbbf24;
    --warning-dim: rgba(251, 191, 36, 0.15);
    --error: #f87171;
    --error-dim: rgba(248, 113, 113, 0.15);
    --info: #60a5fa;
    --info-dim: rgba(96, 165, 250, 0.15);
    
    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    --space-4xl: 80px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.35);
    --shadow-accent: 0 8px 24px rgba(201, 169, 98, 0.2);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;
    
    /* Container Widths */
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1200px;
    
    /* Z-Index Scale */
    --z-base: 1;
    --z-overlay: 10;
    --z-modal: 100;
    --z-toast: 1000;
}

/* ===========================================
   2. BASE RESET & GLOBALS
   =========================================== */

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-primary);
    background-color: var(--bg-deep);
    overflow-x: hidden;
}

/* ===========================================
   3. TYPOGRAPHY
   =========================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 {
    font-size: clamp(2.4rem, 5vw, 3.5rem);
}

h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
}

h3 {
    font-size: clamp(1.4rem, 3vw, 1.75rem);
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.1rem;
}

h6 {
    font-size: 1rem;
}

p {
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

p:last-child {
    margin-bottom: 0;
}

.lead {
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.small {
    font-size: 0.875rem;
}

.tiny {
    font-size: 0.75rem;
}

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

em, i {
    font-style: italic;
}

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

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

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Code */
code, pre, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

code {
    padding: 2px 6px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    color: var(--accent);
}

pre {
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

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

/* Lists */
ul, ol {
    margin-bottom: var(--space-md);
    padding-left: var(--space-lg);
}

li {
    margin-bottom: var(--space-sm);
}

/* Blockquote */
blockquote {
    padding-left: var(--space-lg);
    border-left: 2px solid var(--accent);
    font-style: italic;
    color: var(--text-secondary);
}

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

/* Page Wrapper with grain */
.page-wrapper {
    position: relative;
    min-height: 100vh;
}

.page-wrapper::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201, 169, 98, 0.06), transparent),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139, 118, 64, 0.04), transparent),
        radial-gradient(ellipse 50% 30% at 20% 60%, rgba(201, 169, 98, 0.03), transparent);
    pointer-events: none;
    z-index: 0;
}

.grain-overlay {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1;
}

.content-layer {
    position: relative;
    z-index: 2;
}

/* Containers */
.container {
    width: 100%;
    max-width: var(--container-lg);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-sm {
    max-width: var(--container-sm);
}

.container-md {
    max-width: var(--container-md);
}

.container-xl {
    max-width: var(--container-xl);
}

/* Sections */
.section {
    padding: var(--space-4xl) var(--space-lg);
}

.section-sm {
    padding: var(--space-2xl) var(--space-lg);
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.section-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
    margin-bottom: var(--space-md);
}

.section-title {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
}

.section-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Grid */
.grid {
    display: grid;
    gap: var(--space-lg);
}

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

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

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

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

/* Flex */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-center {
    align-items: center;
    justify-content: center;
}

.flex-between {
    justify-content: space-between;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ===========================================
   5. CARDS
   =========================================== */

.card {
    padding: var(--space-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-light);
}

.card-accent {
    border-color: var(--border-accent);
    background: linear-gradient(135deg, var(--bg-card), rgba(201, 169, 98, 0.03));
}

.card-accent:hover {
    border-color: var(--accent-muted);
}

.card-featured {
    border-color: var(--accent-muted);
    background: linear-gradient(135deg, var(--bg-card), rgba(201, 169, 98, 0.05));
}

.card-elevated {
    background: var(--bg-elevated);
    box-shadow: var(--shadow-lg);
}

/* Card Header */
.card-header {
    margin-bottom: var(--space-lg);
}

.card-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 400;
    margin-bottom: var(--space-sm);
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ===========================================
   6. BUTTONS
   =========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover {
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
}

.btn-outline {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent-dim);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

/* Button Sizes */
.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1rem;
}

/* Button with icon */
.btn svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-base);
}

.btn:hover svg {
    transform: translateX(3px);
}

/* ===========================================
   7. FORMS
   =========================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 14px 16px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

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

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-error {
    font-size: 0.85rem;
    color: var(--error);
}

/* Form Submit */
.form-submit {
    padding: 14px 28px;
    background: var(--accent);
    color: var(--text-inverse);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.form-submit:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ===========================================
   8. BADGES & TAGS
   =========================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-success {
    background: var(--success-dim);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-dim);
    color: var(--warning);
}

.badge-error {
    background: var(--error-dim);
    color: var(--error);
}

.badge-info {
    background: var(--info-dim);
    color: var(--info);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 4px 10px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* ===========================================
   9. METRICS
   =========================================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-lg);
}

.metric {
    text-align: center;
    padding: var(--space-md);
}

.metric-value {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.metric-accent .metric-value {
    color: var(--accent);
}

/* Metrics Strip */
.metrics-strip {
    padding: var(--space-2xl) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(20, 20, 22, 0.5);
}

/* ===========================================
   10. ICONS (SVG helpers)
   =========================================== */

.icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-lg {
    width: 32px;
    height: 32px;
}

.icon-box {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    border-radius: var(--radius-md);
}

.icon-box svg {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
}

/* ===========================================
   11. DIVIDERS & SEPARATORS
   =========================================== */

.divider {
    width: 100%;
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-2xl) 0;
}

.divider-accent {
    background: linear-gradient(90deg, transparent, var(--accent-muted), transparent);
}

/* ===========================================
   12. UTILITY CLASSES
   =========================================== */

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

/* Text Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }

/* Background Colors */
.bg-deep { background-color: var(--bg-deep); }
.bg-elevated { background-color: var(--bg-elevated); }
.bg-card { background-color: var(--bg-card); }

/* Display */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }

/* Spacing */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

/* Width */
.w-full { width: 100%; }
.max-w-prose { max-width: 65ch; }

/* ===========================================
   13. RESPONSIVE BREAKPOINTS
   =========================================== */

@media (max-width: 768px) {
    :root {
        --space-4xl: 60px;
        --space-3xl: 48px;
    }
    
    .section {
        padding: var(--space-3xl) var(--space-md);
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 0 var(--space-md);
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.6rem;
    }
    
    .btn {
        padding: 10px 20px;
    }
    
    .btn-lg {
        padding: 12px 24px;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .metric-value {
        font-size: 1.8rem;
    }
}

/* ===========================================
   14. ANIMATIONS
   =========================================== */

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.animate-fade-in {
    animation: fadeIn var(--transition-slow) ease forwards;
}

.animate-slide-up {
    animation: slideUp var(--transition-slow) ease forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Stagger delays */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* ===========================================
   15. REDUCED MOTION
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}
