/* ========================================
   hAIppy day — Redesign 2026
   Editorial / Archival aesthetic
   ======================================== */

/* ========================================
   CSS Custom Properties
   ======================================== */
:root {
    /* Light Theme — warm, papery, editorial */
    --bg: #f5f0e8;
    --bg-alt: #ede7db;
    --surface: #faf8f3;
    --text: #2c2416;
    --text-secondary: #7a6f5f;
    --text-tertiary: #a39882;
    --accent: #c45d3e;
    --accent-hover: #a84a2e;
    --border: #d8d0c0;
    --border-light: #e8e2d6;
    --shadow: rgba(44, 36, 22, 0.06);
    --shadow-md: rgba(44, 36, 22, 0.1);

    /* Typography */
    --font-display: 'DM Serif Display', serif;
    --font-body: 'Source Serif 4', serif;
    --font-mono: 'Space Mono', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;
    --space-3xl: 6rem;

    --max-width: 680px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1714;
        --bg-alt: #221f1a;
        --surface: #2a2520;
        --text: #e8e0d4;
        --text-secondary: #a09585;
        --text-tertiary: #706558;
        --accent: #e07a5a;
        --accent-hover: #eb9070;
        --border: #3a342c;
        --border-light: #302b24;
        --shadow: rgba(0, 0, 0, 0.15);
        --shadow-md: rgba(0, 0, 0, 0.25);
    }
}

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

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

body {
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition), color var(--transition);
}

a {
    color: inherit;
    text-decoration: none;
}

::selection {
    background-color: var(--accent);
    color: #fff;
}

/* ========================================
   Header
   ======================================== */
header {
    padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
    text-align: center;
    position: relative;
}

header::after {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    background: var(--accent);
    margin: var(--space-xl) auto 0;
}

.site-title {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text);
    margin-bottom: var(--space-sm);
}

.site-title a {
    transition: color var(--transition);
}

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

.site-subtitle {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* ========================================
   Main Content
   ======================================== */
main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-lg) var(--space-3xl);
}

/* ========================================
   Post List
   ======================================== */
.post-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.post-item {
    padding: var(--space-2xl) 0;
    border-bottom: 1px solid var(--border-light);
    opacity: 0;
    animation: fadeUp 0.5s ease forwards;
}

.post-item:first-child {
    padding-top: 0;
}

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

/* Date */
.post-date {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--space-md);
    transition: color var(--transition);
    position: relative;
}

.post-date:hover {
    color: var(--accent);
}

.post-date::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent);
    transition: width var(--transition);
}

.post-date:hover::before {
    width: 100%;
}

/* Prompt */
.prompt {
    font-family: var(--font-display);
    font-size: 1.35rem;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: var(--space-lg);
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* Reply */
.reply {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-secondary);
    position: relative;
    padding-left: var(--space-lg);
}

.reply::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.35em;
    bottom: 0.35em;
    width: 2px;
    background: var(--border);
    border-radius: 1px;
    transition: background var(--transition);
}

.post-item:hover .reply::before {
    background: var(--accent);
}

.reply p {
    margin-bottom: var(--space-md);
}

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

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

.reply em {
    font-style: italic;
}

.reply h2,
.reply h3,
.reply h4 {
    font-family: var(--font-display);
    color: var(--text);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

/* ========================================
   Single Post View
   ======================================== */
#post-detail {
    display: none;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--space-2xl);
    padding: var(--space-sm) 0;
    transition: color var(--transition);
}

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

.back-button svg {
    width: 14px;
    height: 14px;
    transition: transform var(--transition);
}

.back-button:hover svg {
    transform: translateX(-3px);
}

.single-post .single-post-date {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--space-lg);
    font-weight: 400;
}

.single-post .prompt {
    font-size: 1.6rem;
    margin-bottom: var(--space-xl);
}

.single-post .reply {
    font-size: 1.1rem;
}

/* ========================================
   Loading State
   ======================================== */
.loading {
    text-align: center;
    padding: var(--space-3xl) 0;
    color: var(--text-tertiary);
}

.loading-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    margin: 0 3px;
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 80%, 100% {
        opacity: 0.2;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

.loading p {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: var(--space-md);
}

/* ========================================
   Footer
   ======================================== */
footer {
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    border-top: 1px solid var(--border-light);
}

footer p {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
    html {
        font-size: 16px;
    }

    header {
        padding: var(--space-2xl) var(--space-md) var(--space-xl);
    }

    main {
        padding: 0 var(--space-md) var(--space-2xl);
    }

    .post-item {
        padding: var(--space-xl) 0;
    }

    .prompt {
        font-size: 1.2rem;
    }

    .reply {
        font-size: 1rem;
        padding-left: var(--space-md);
    }

    .single-post .prompt {
        font-size: 1.35rem;
    }
}

/* ========================================
   Print
   ======================================== */
@media print {
    header::after,
    footer,
    .back-button {
        display: none;
    }

    .post-item {
        break-inside: avoid;
        border: none;
    }

    .reply::before {
        background: #999;
    }
}

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

/* Focus */
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}
