/* ===================================================================
   lovely.day -- daily log of lovely moments
   Burgundy terminal aesthetic with diagonal-section transitions.
   =================================================================== */

:root {
    /* Palette (deep-burgundy) */
    --bg-deep: #2a0e14;
    --bg-deeper: #1a0a10;
    --terminal-surface: #1a0a10;
    --terminal-border: #4a1a24;
    --text-primary: #d4a0a8;
    --text-secondary: #8a5060;
    --cursor: #d4a0a8;
    --pulse: #e06070;
    --bar-1: #8a3040;
    --bar-2: #b04858;
    --bar-3: #d06070;
    --blob: rgba(74, 26, 36, 0.40);

    /* Type */
    --font-mono: "Inconsolata", "JetBrains Mono", "Menlo", "Consolas", monospace;
}

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

html {
    scroll-behavior: smooth;
    background: var(--bg-deep);
}

body {
    font-family: var(--font-mono);
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-deep);
    line-height: 1.65;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    min-height: 100vh;
    font-feature-settings: "liga" 0, "calt" 0;
}

/* ============ Section base ============ */
.section {
    position: relative;
    width: 100%;
    padding: clamp(48px, 9vh, 96px) clamp(20px, 5vw, 80px);
    overflow: hidden;
}

.section-inner {
    position: relative;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    z-index: 2;
}

.section-header {
    margin-bottom: clamp(24px, 4vh, 48px);
    border-bottom: 1px dashed var(--terminal-border);
    padding-bottom: 16px;
}

.section-label {
    font-family: var(--font-mono);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: clamp(20px, 3vw, 32px);
    color: var(--text-primary);
    line-height: 1;
}

.section-meta {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: clamp(13px, 1.3vw, 15px);
    letter-spacing: 0.02em;
}

/* ============ Hero / Opening ============ */
.section-hero {
    background: var(--bg-deep);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding-top: clamp(64px, 12vh, 120px);
    padding-bottom: clamp(80px, 16vh, 160px);
    /* Diagonal cut at the bottom (8deg) */
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 5vw), 0 100%);
}

.terminal-panel {
    position: relative;
    width: 90vw;
    max-width: 800px;
    background: var(--terminal-surface);
    border: 1px solid var(--terminal-border);
    border-radius: 4px;
    box-shadow:
        0 0 0 1px rgba(74, 26, 36, 0.35),
        0 30px 80px -30px rgba(0, 0, 0, 0.8),
        inset 0 0 60px rgba(74, 26, 36, 0.20);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 400ms ease, transform 600ms ease;
    z-index: 2;
}

.terminal-panel.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--terminal-border);
    background: linear-gradient(180deg, rgba(74, 26, 36, 0.30), rgba(74, 26, 36, 0.10));
}

.terminal-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--terminal-border);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.terminal-dot-1 { background: var(--bar-1); }
.terminal-dot-2 { background: var(--bar-2); }
.terminal-dot-3 { background: var(--bar-3); }

.terminal-title {
    margin-left: 10px;
    font-family: var(--font-mono);
    font-size: clamp(12px, 1.3vw, 14px);
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: lowercase;
}

.terminal-body {
    padding: clamp(20px, 3.4vw, 36px) clamp(20px, 3vw, 32px);
    min-height: 180px;
}

.terminal-meta {
    color: var(--text-secondary);
    font-size: clamp(12px, 1.2vw, 14px);
    margin-bottom: 18px;
    opacity: 0.85;
}

.terminal-line {
    font-size: clamp(15px, 1.7vw, 19px);
    color: var(--text-primary);
    word-break: break-word;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5ch;
    line-height: 1.5;
}

.prompt-glyph {
    color: var(--bar-2);
    font-weight: 700;
    margin-right: 0.2ch;
}

.typed-text {
    white-space: pre-wrap;
}

.terminal-subline {
    margin-top: 18px;
    color: var(--text-secondary);
    font-size: clamp(12px, 1.2vw, 14px);
    opacity: 0.8;
}

/* ============ Cursor ============ */
.terminal-cursor {
    display: inline-block;
    color: var(--cursor);
    font-size: 1em;
    margin-left: 1px;
    line-height: 1;
    animation: cursorBlink 1s steps(2, jump-none) infinite;
}

.cursor-static {
    color: var(--cursor);
    margin-left: 4px;
}

@keyframes cursorBlink {
    0%, 49%   { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* ============ Hero marquee ============ */
.hero-marquee {
    position: absolute;
    bottom: clamp(24px, 5vh, 48px);
    left: 0;
    right: 0;
    display: flex;
    gap: 0;
    overflow: hidden;
    pointer-events: none;
    color: var(--terminal-border);
    font-family: var(--font-mono);
    font-size: clamp(11px, 1.1vw, 13px);
    letter-spacing: 0.18em;
    text-transform: lowercase;
    opacity: 0.55;
    z-index: 1;
}

.hero-marquee span {
    flex-shrink: 0;
    white-space: nowrap;
    padding-right: 1.5ch;
    animation: marquee 40s linear infinite;
}

@keyframes marquee {
    from { transform: translateX(0); }
    to   { transform: translateX(-100%); }
}

/* ============ Log section (diagonal +8deg cut top, returns flat) ============ */
.section-log {
    background: #240a10;
    /* Top diagonal cut overlapping the hero by 40px */
    margin-top: -40px;
    padding-top: clamp(96px, 14vh, 160px);
    clip-path: polygon(0 5vw, 100% 0, 100% 100%, 0 calc(100% - 5vw));
}

.log-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.log-entry {
    position: relative;
    display: grid;
    grid-template-columns: minmax(155px, 175px) 1fr 22px;
    gap: 16px;
    align-items: baseline;
    padding: 12px 16px;
    background: var(--terminal-surface);
    border: 1px solid var(--terminal-border);
    border-radius: 2px;
    font-size: clamp(14px, 1.5vw, 17px);
    line-height: 1.55;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 400ms ease, transform 500ms ease, border-color 300ms ease, background 300ms ease;
}

.log-entry.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.log-entry.is-current {
    background: linear-gradient(90deg, var(--terminal-surface), rgba(74, 26, 36, 0.55));
    border-color: var(--bar-2);
}

.log-stamp {
    color: var(--text-secondary);
    font-weight: 400;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.log-text {
    color: var(--text-primary);
    word-break: break-word;
}

.log-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pulse);
    justify-self: end;
    align-self: center;
    opacity: 0;
    box-shadow: 0 0 14px rgba(224, 96, 112, 0.65);
    transition: opacity 200ms ease;
}

.log-entry.is-current .log-pulse {
    opacity: 1;
    animation: pulseAttention 2s ease-in-out infinite;
}

@keyframes pulseAttention {
    0%, 100% { opacity: 0.4; transform: scale(0.95); }
    50%      { opacity: 1.0; transform: scale(1.15); }
}

.log-footer {
    margin-top: 28px;
    padding: 14px 16px;
    border-top: 1px dashed var(--terminal-border);
    color: var(--text-secondary);
    font-size: clamp(13px, 1.3vw, 15px);
    display: flex;
    align-items: baseline;
    gap: 0.5ch;
}

.log-footer-text {
    word-break: break-all;
}

/* ============ Patterns section (diagonal -8deg cut) ============ */
.section-patterns {
    background: var(--bg-deeper);
    margin-top: -40px;
    padding-top: clamp(96px, 14vh, 160px);
    clip-path: polygon(0 0, 100% 5vw, 100% calc(100% - 5vw), 0 100%);
}

.blob-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-52%, -50%);
    width: clamp(560px, 88vw, 1080px);
    height: clamp(420px, 70vh, 720px);
    background: var(--blob);
    border-radius: 62% 38% 55% 45% / 48% 56% 44% 52%;
    filter: blur(8px);
    z-index: 0;
    pointer-events: none;
    animation: blobMorph 18s ease-in-out infinite alternate;
}

@keyframes blobMorph {
    0%   { border-radius: 62% 38% 55% 45% / 48% 56% 44% 52%; transform: translate(-52%, -50%) rotate(0deg); }
    50%  { border-radius: 48% 52% 38% 62% / 56% 44% 60% 40%; transform: translate(-50%, -52%) rotate(8deg); }
    100% { border-radius: 58% 42% 64% 36% / 42% 58% 50% 50%; transform: translate(-54%, -48%) rotate(-6deg); }
}

.patterns-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr);
    gap: clamp(20px, 4vw, 56px);
    align-items: start;
}

.patterns-chart {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: clamp(20px, 3vw, 32px) clamp(20px, 3vw, 32px);
    background: rgba(26, 10, 16, 0.65);
    border: 1px solid var(--terminal-border);
    border-radius: 2px;
}

.chart-row {
    display: grid;
    grid-template-columns: 110px 1fr 50px;
    gap: 16px;
    align-items: center;
    font-size: clamp(13px, 1.4vw, 16px);
}

.chart-label {
    color: var(--text-secondary);
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

.chart-bar {
    position: relative;
    display: block;
    height: 14px;
    background: rgba(74, 26, 36, 0.30);
    border: 1px solid rgba(74, 26, 36, 0.6);
    overflow: hidden;
}

.chart-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--bar-2);
    transition: width 600ms cubic-bezier(0.22, 0.61, 0.36, 1);
    background-image:
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.06) 0,
            rgba(255, 255, 255, 0.06) 10px,
            transparent 10px,
            transparent 12px
        );
}

.chart-row[data-shade="1"] .chart-fill { background-color: var(--bar-1); }
.chart-row[data-shade="2"] .chart-fill { background-color: var(--bar-2); }
.chart-row[data-shade="3"] .chart-fill { background-color: var(--bar-3); }

.chart-count {
    color: var(--text-primary);
    text-align: right;
    font-weight: 700;
    opacity: 0;
    transition: opacity 200ms ease 100ms;
}

.chart-row.is-filled .chart-count {
    opacity: 1;
}

.patterns-readout {
    padding: clamp(20px, 3vw, 32px);
    background: rgba(26, 10, 16, 0.65);
    border: 1px solid var(--terminal-border);
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: clamp(13px, 1.3vw, 15px);
}

.readout-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(74, 26, 36, 0.55);
}

.readout-line:last-child { border-bottom: none; }

.readout-key {
    color: var(--text-secondary);
    text-transform: lowercase;
    letter-spacing: 0.05em;
}

.readout-val {
    color: var(--text-primary);
    font-weight: 700;
}

/* ============ Tonight / Closing ============ */
.section-tonight {
    background: var(--bg-deep);
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    margin-top: -40px;
    padding-top: clamp(96px, 14vh, 160px);
    clip-path: polygon(0 5vw, 100% 0, 100% 100%, 0 100%);
    background-image: radial-gradient(ellipse at center, #320e15 0%, #1a070d 90%);
}

.terminal-panel-closing {
    background: var(--terminal-surface);
}

.page-footer {
    margin-top: clamp(40px, 7vh, 80px);
    color: var(--text-secondary);
    font-size: clamp(12px, 1.2vw, 14px);
    letter-spacing: 0.06em;
    text-transform: lowercase;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    opacity: 0.75;
}

.footer-sep {
    color: var(--bar-2);
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .terminal-cursor { animation: none; opacity: 1; }
}

/* ============ Responsive ============ */
@media (max-width: 720px) {
    .section-hero { clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8vw), 0 100%); }
    .section-log { clip-path: polygon(0 8vw, 100% 0, 100% 100%, 0 calc(100% - 8vw)); }
    .section-patterns { clip-path: polygon(0 0, 100% 8vw, 100% calc(100% - 8vw), 0 100%); }
    .section-tonight { clip-path: polygon(0 8vw, 100% 0, 100% 100%, 0 100%); }

    .log-entry {
        grid-template-columns: 1fr 22px;
        grid-template-rows: auto auto;
        row-gap: 4px;
    }
    .log-stamp { grid-column: 1 / 2; grid-row: 1 / 2; }
    .log-text  { grid-column: 1 / 3; grid-row: 2 / 3; }
    .log-pulse { grid-column: 2 / 3; grid-row: 1 / 2; }

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

    .chart-row {
        grid-template-columns: 90px 1fr 40px;
        gap: 10px;
    }
}
