/* --- 1. THEME & TYPOGRAPHY --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700&family=Roboto+Mono:wght@400;500&display=swap');

:root {
    /* Semantic color variables - named by purpose, not appearance */
    --bg-primary:    #EDE6D9;   /* Page background - warm paper */
    --bg-secondary:  #FEFAF2;   /* Bento box background */
    --text-primary:  #2C2720;   /* Headings and strong text */
    --text-muted:    #5D574F;   /* Body copy and feed content */
    --text-subtle:   #8C8479;   /* Social icons, secondary UI */
    --border:        #D6C8B2;   /* Box borders */
    --accent:        #A0522D;   /* Burnt sienna - all interactive highlights */
    --accent-glow:   rgba(160, 82, 45, 0.1); /* Hover shadow */
    --transition:    all 0.3s ease;
}

/* Dark mode - warm dark palette, keeps sienna identity */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary:   #1A1512;   /* Deep warm dark - page background */
        --bg-secondary: #231E1A;   /* Slightly lighter warm dark - boxes */
        --text-primary: #EDE6D9;   /* Warm off-white - was the light bg */
        --text-muted:   #A89F94;   /* Warm mid-gray */
        --text-subtle:  #6B6259;   /* Dimmed for icons */
        --border:       #3A322B;   /* Dark warm border */
        --accent:       #C4693A;   /* Slightly lighter sienna for dark bg contrast */
        --accent-glow:  rgba(196, 105, 58, 0.15);
    }
}

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

/* --- 2. GLOBAL FOUNDATION --- */
body {
    background-color: var(--bg-primary);
    margin: 0;
    padding: 40px 20px;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
}

/* --- 3. ACCESSIBILITY - FOCUS STATES --- */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* --- 4. HEADER & INTRO --- */
.hero-header h1 {
    font-size: 2rem;
    margin: 0;
}

.floating-intro {
    grid-column: span 4;
    text-align: center;
    padding: 20px 0;
    margin: 10px 0;
}

/* --- 5. GRID SYSTEM & BOX STRUCTURE --- */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-width: 1200px;
    width: 100%;
}

.bento-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 24px;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 300px;
    transition: var(--transition);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}

.header-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.compact {
    height: auto !important;
    min-height: 80px;
    padding: 20px 24px;
    justify-content: center;
}

.bento-box:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px var(--accent-glow);
}

.full-width { grid-column: span 4 !important; }
.half-width { grid-column: span 2 !important; }

/* --- 6. ANIMATIONS (GLOW, SWEEP, PULSE) --- */

/* Heatmap Glow */
.heat-map {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    margin: 15px auto;
    width: fit-content;
}

.tile {
    background-color: rgba(160, 82, 45, 0.15);
    border-radius: 2px;
    width: 14px;
    height: 14px;
    animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { opacity: 1; background-color: rgba(160, 82, 45, 0.15); }
    50%       { opacity: 0.1; background-color: rgba(160, 82, 45, 0.05); }
}

.tile:nth-child(3n) { animation-delay: 0.5s; }
.tile:nth-child(5n) { animation-delay: 1.2s; }

/* Static heat levels - no animation */
.lvl-5, .lvl-3, .lvl-1 { animation: none !important; opacity: 1 !important; }
.lvl-5 { background-color: var(--accent); }
.lvl-3 { background-color: rgba(160, 82, 45, 0.6); }
.lvl-1 { background-color: rgba(160, 82, 45, 0.2); }

/* Clock Sweep */
.dial {
    width: 80px;
    height: 80px;
    border: 1px solid var(--border);
    border-radius: 50%;
    position: relative;
    margin: 10px auto;
    flex-shrink: 0;
}

.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    width: 2px;
    height: 32px;
    background: var(--accent);
    transform-origin: bottom;
    animation: sweep 60s linear infinite;
}

@keyframes sweep {
    from { transform: translateX(-50%) rotate(0deg); }
    to   { transform: translateX(-50%) rotate(360deg); }
}

/* Cursor Pulse */
.writing-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 80px;
    padding-left: 4px;
}

.writing-cursor {
    font-family: 'Inter', sans-serif;
    font-size: 1.8rem;
    color: var(--accent);
    font-weight: 300;
    line-height: 1;
}

.writing-cursor::after {
    content: "|";
    animation: cursorPulse 3s ease-in-out infinite;
}

@keyframes cursorPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.15; }
}

/* --- 7. FEED & TYPOGRAPHY --- */
.label {
    font-family: 'Roboto Mono', monospace;
    color: var(--accent);
    font-size: 0.75rem;
    display: block;
    line-height: 1.3;
}

.bento-box h2 {
    font-size: 1.6rem;
    margin: 0;
    font-weight: 700;
    color: var(--text-primary);
}

.title-link {
    text-decoration: none;
    color: var(--text-primary);
}

.title-link:hover h2,
.title-link:focus-visible h2 {
    color: var(--accent);
    transition: var(--transition);
}

.latest-feed {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feed-prefix {
    color: var(--accent);
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.feed-content {
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.feed-link {
    display: inline-block;
    text-decoration: none;
    color: var(--text-primary);
    font-family: "Charter", "Georgia", serif;
    font-size: 0.95rem;
    line-height: 1.3;
    width: auto;
    transition: border-color 0.2s ease;
    border-bottom: 1px solid transparent;
}

.feed-link:hover,
.feed-link:focus-visible {
    border-bottom: 1px solid var(--accent);
    color: var(--accent);
}

/* --- 8. RESPONSIVE --- */
@media (max-width: 768px) {
    body { padding: 20px 15px; }

    .bento-grid { grid-template-columns: 1fr !important; }

    .bento-box,
    .full-width,
    .half-width,
    .hero-header,
    .floating-intro {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        height: auto;
        min-height: 220px;
    }

    .hero-header.compact {
        min-height: 60px !important;
        padding: 15px 20px !important;
        text-align: center;
    }

    .floating-intro { min-height: auto; padding: 10px 0; }

    .heat-map, .dial { margin: 20px auto; }
    .writing-area { justify-content: flex-start; padding-left: 0; margin: 10px 0; }
}

/* --- 9. UTILITIES & FOOTER --- */
hr {
    border: 0;
    height: 1px;
    width: 100%;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    margin: 40px 0 20px 0;
    opacity: 0.4;
}

.social-footer {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding-bottom: 40px;
}

.social-icon {
    font-size: 1.5rem;
    color: var(--text-subtle);
    text-decoration: none;
    transition: var(--transition);
}

.social-icon:hover,
.social-icon:focus-visible {
    color: var(--accent);
    transform: translateY(-3px);
}
