/* =============================================================
   lunatic.dev — v2
   Sepia-Nostalgic Terminal Aesthetic
   ============================================================= */

:root {
    /* Palette per DESIGN.md */
    --c-paper: #F0E8D8;        /* Old Paper — primary background */
    --c-paper-light: #FAF4E8;  /* Cream Light — card backgrounds */
    --c-paper-band: #E8DCC8;   /* Skeleton band */
    --c-term-dark: #1A1812;    /* Terminal Dark */
    --c-term-darker: #2A2418;  /* Title bar — slightly raised */
    --c-amber: #D4A84B;        /* Phosphor Amber */
    --c-amber-soft: #B8923A;
    --c-bronze: #8B7355;       /* Mid bronze accent */
    --c-shade: #5A4A35;        /* Faded ink */
    --c-warm-gray: #A0927A;    /* Warm gray, comments */
    --c-bubble: #7AB0C8;       /* Bubble Blue */

    /* Type */
    --f-rec: 'Recursive', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;

    /* Motion */
    --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
    --dur-slow: 1200ms;
    --dur-mid: 600ms;
}

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

html, body {
    background: var(--c-paper);
    color: var(--c-shade);
    font-family: var(--f-rec);
    font-variation-settings: "MONO" 0, "CASL" 0.4, "wght" 400, "slnt" 0;
    font-size: clamp(15px, 1.05vw, 18px);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Subtle paper grain — layered radial spots */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 14% 22%, rgba(90, 74, 53, 0.05), transparent 40%),
        radial-gradient(ellipse at 86% 78%, rgba(90, 74, 53, 0.04), transparent 45%),
        radial-gradient(ellipse at 50% 110%, rgba(212, 168, 75, 0.06), transparent 50%);
    z-index: 0;
}

.page-frame {
    position: relative;
    z-index: 1;
}

/* =============================================================
   Bubble Field — meditative ambient
   ============================================================= */

.bubble-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(
        circle at 32% 30%,
        rgba(255, 255, 255, 0.55) 0%,
        rgba(255, 255, 255, 0.18) 18%,
        rgba(122, 176, 200, 0.20) 60%,
        rgba(122, 176, 200, 0.05) 100%
    );
    border: 0.5px solid rgba(122, 176, 200, 0.28);
    box-shadow:
        inset 0 0 6px rgba(255, 255, 255, 0.18),
        0 0 14px rgba(122, 176, 200, 0.10);
    animation-name: bubbleRise, bubbleSway;
    animation-iteration-count: infinite, infinite;
    animation-timing-function: linear, ease-in-out;
    will-change: transform, opacity;
    opacity: 0;
}

@keyframes bubbleRise {
    0%   { transform: translateY(0vh) translateX(0); opacity: 0; }
    8%   { opacity: 0.85; }
    92%  { opacity: 0.85; }
    100% { transform: translateY(-115vh) translateX(0); opacity: 0; }
}

@keyframes bubbleSway {
    0%, 100% { margin-left: 0; }
    25%      { margin-left: 6px; }
    50%      { margin-left: -4px; }
    75%      { margin-left: 5px; }
}

/* =============================================================
   Hero — Full-Viewport Terminal
   ============================================================= */

.hero {
    position: relative;
    min-height: 100vh;
    padding: 6vh 5vw 4vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.hero-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        ellipse at center,
        transparent 30%,
        rgba(90, 74, 53, 0.10) 80%,
        rgba(42, 36, 24, 0.20) 100%
    );
}

.terminal {
    position: relative;
    width: min(80vw, 1180px);
    height: 70vh;
    min-height: 520px;
    background: var(--c-term-dark);
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        0 30px 80px rgba(42, 36, 24, 0.32),
        0 8px 24px rgba(42, 36, 24, 0.18),
        inset 0 0 0 1px rgba(212, 168, 75, 0.08);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    opacity: 0;
    animation: termAppear 1100ms var(--ease-soft) 200ms forwards;
}

@keyframes termAppear {
    to { transform: translateY(0); opacity: 1; }
}

.terminal-titlebar {
    background: var(--c-term-darker);
    height: 38px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 14px;
    border-bottom: 1px solid rgba(212, 168, 75, 0.06);
    flex-shrink: 0;
}

.dots {
    display: flex;
    gap: 7px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.3);
}

.dot-amber  { background: var(--c-amber); }
.dot-bronze { background: var(--c-bronze); }
.dot-shade  { background: var(--c-shade); }

.title {
    flex: 1;
    text-align: center;
    color: var(--c-warm-gray);
    font-size: 12px;
    font-variation-settings: "MONO" 1, "CASL" 0;
    letter-spacing: 0.02em;
    user-select: none;
}

.moon-indicator {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.terminal-body {
    flex: 1;
    position: relative;
    padding: 28px 32px;
    overflow: hidden;
    color: var(--c-amber);
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 400;
    font-size: clamp(13px, 1vw, 16px);
    line-height: 1.65;
}

.scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.06) 1px,
        rgba(0, 0, 0, 0.06) 2px
    );
    mix-blend-mode: multiply;
    opacity: 0.85;
}

.phosphor-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        ellipse at 50% 35%,
        rgba(212, 168, 75, 0.08),
        transparent 65%
    );
    animation: phosphorBreathe 6s ease-in-out infinite;
}

@keyframes phosphorBreathe {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}

/* Skeleton inside terminal */
.skeleton-stack {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: opacity 500ms var(--ease-soft);
}

.skeleton-stack.gone {
    opacity: 0;
    pointer-events: none;
}

.skeleton-bar {
    height: 14px;
    border-radius: 3px;
    background:
        linear-gradient(
            90deg,
            rgba(212, 168, 75, 0.10) 25%,
            rgba(212, 168, 75, 0.22) 50%,
            rgba(212, 168, 75, 0.10) 75%
        );
    background-size: 200% 100%;
    animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Real terminal content */
.terminal-content {
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 500ms var(--ease-soft);
}

.terminal-content.visible {
    opacity: 1;
}

.ascii-logo {
    color: var(--c-amber);
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 700;
    font-size: clamp(8px, 0.86vw, 13px);
    line-height: 1.05;
    margin-bottom: 18px;
    text-shadow: 0 0 6px rgba(212, 168, 75, 0.25);
    white-space: pre;
}

.terminal-line {
    margin: 4px 0;
    color: var(--c-amber);
    text-shadow: 0 0 5px rgba(212, 168, 75, 0.18);
}

.terminal-line .prompt { color: var(--c-bubble); }
.terminal-line .sep    { color: var(--c-warm-gray); margin: 0 1px; }
.terminal-line .path   { color: var(--c-amber-soft); }
.terminal-line .cmd    { color: var(--c-paper-light); }
.terminal-line.answer  { color: var(--c-warm-gray); padding-left: 0; margin-top: 2px; margin-bottom: 12px; }

.cursor {
    display: inline-block;
    color: var(--c-amber);
    margin-left: 2px;
    animation: blink 530ms steps(1, end) infinite;
    text-shadow: 0 0 8px rgba(212, 168, 75, 0.5);
}

@keyframes blink {
    0%, 50%   { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.terminal-footer {
    background: var(--c-term-darker);
    border-top: 1px solid rgba(212, 168, 75, 0.06);
    padding: 8px 16px;
    color: var(--c-warm-gray);
    font-size: 11px;
    font-variation-settings: "MONO" 1, "CASL" 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c-amber);
    box-shadow: 0 0 6px var(--c-amber);
    animation: phosphorBreathe 3.2s ease-in-out infinite;
}

/* Hero marquee under terminal */
.hero-marquee {
    margin-top: 32px;
    width: 100%;
    overflow: hidden;
    position: relative;
    color: var(--c-bronze);
    font-variation-settings: "MONO" 0.4, "CASL" 0.6, "wght" 400, "slnt" -8;
    font-size: 13px;
    letter-spacing: 0.05em;
    opacity: 0;
    animation: fadeIn 800ms var(--ease-soft) 1.4s forwards;
}

.hero-marquee span {
    display: inline-block;
    padding-right: 40px;
    white-space: nowrap;
    animation: marquee 38s linear infinite;
}

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

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

/* =============================================================
   Boundary — terminal to paper
   ============================================================= */

.boundary {
    position: relative;
    height: 180px;
    z-index: 3;
}

.boundary-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        var(--c-paper) 0%,
        var(--c-paper) 100%
    );
}

.boundary-ascii {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-bronze);
    font-variation-settings: "MONO" 1;
    opacity: 0.45;
    font-size: 12px;
    letter-spacing: 0.05em;
}

/* =============================================================
   Sections — paper layouts
   ============================================================= */

.section {
    position: relative;
    padding: 100px 6vw;
    z-index: 3;
    max-width: 1280px;
    margin: 0 auto;
}

/* Skeleton overlay (in front before reveal) */
.skeleton-overlay {
    position: absolute;
    inset: 100px 6vw 100px 6vw;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: opacity 500ms var(--ease-soft), transform 500ms var(--ease-soft);
    pointer-events: none;
}

.section .real-content {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms var(--ease-soft) 100ms, transform 500ms var(--ease-soft) 100ms;
}

.section.loaded .skeleton-overlay {
    opacity: 0;
    transform: translateY(-8px);
}

.section.loaded .real-content {
    opacity: 1;
    transform: translateY(0);
}

.skeleton-overlay .skeleton-bar {
    height: 14px;
    background:
        linear-gradient(
            90deg,
            var(--c-paper-band) 25%,
            var(--c-paper) 50%,
            var(--c-paper-band) 75%
        );
    background-size: 200% 100%;
    animation: shimmer 1.6s linear infinite;
    border-radius: 3px;
}

.skel-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-top: 18px;
}

.skel-card {
    height: 180px;
    border-radius: 10px;
    background:
        linear-gradient(
            90deg,
            var(--c-paper-band) 25%,
            var(--c-paper) 50%,
            var(--c-paper-band) 75%
        );
    background-size: 200% 100%;
    animation: shimmer 1.6s linear infinite;
}

.section-tag {
    color: var(--c-bronze);
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 500;
    font-size: 13px;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
    text-transform: lowercase;
}

.section-heading {
    color: var(--c-term-dark);
    font-variation-settings: "MONO" 0, "CASL" 0.8, "wght" 500, "slnt" 0;
    font-size: clamp(28px, 3.6vw, 56px);
    line-height: 1.1;
    margin-bottom: 28px;
    max-width: 22ch;
    letter-spacing: -0.01em;
}

.lede {
    color: var(--c-shade);
    font-size: clamp(16px, 1.2vw, 19px);
    max-width: 64ch;
    margin-bottom: 18px;
    font-variation-settings: "MONO" 0, "CASL" 0.6, "wght" 400;
}

.lede em {
    color: var(--c-amber-soft);
    font-style: normal;
    font-variation-settings: "MONO" 0, "CASL" 0.6, "wght" 500, "slnt" -10;
}

/* =============================================================
   Catalog grid
   ============================================================= */

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 22px;
    margin-top: 12px;
}

.catalog-card {
    position: relative;
    background: var(--c-paper-light);
    border: 1px solid var(--c-paper-band);
    border-radius: 10px;
    padding: 26px 24px 24px;
    transition: transform 350ms var(--ease-soft), box-shadow 350ms var(--ease-soft), border-color 350ms;
    overflow: hidden;
    cursor: pointer;
}

.catalog-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at 100% 0%,
        rgba(212, 168, 75, 0.10),
        transparent 50%
    );
    opacity: 0;
    transition: opacity 350ms;
    pointer-events: none;
}

.catalog-card:hover {
    transform: translateY(-3px);
    box-shadow:
        0 12px 32px rgba(90, 74, 53, 0.12),
        0 4px 10px rgba(90, 74, 53, 0.06);
    border-color: var(--c-amber-soft);
}

.catalog-card:hover::before {
    opacity: 1;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    color: var(--c-warm-gray);
    font-variation-settings: "MONO" 1, "CASL" 0;
    font-size: 12px;
    letter-spacing: 0.04em;
}

.card-num {
    color: var(--c-amber-soft);
    font-variation-settings: "MONO" 1, "wght" 700;
}

.card-title {
    color: var(--c-term-dark);
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 600;
    font-size: clamp(22px, 2vw, 30px);
    margin-bottom: 12px;
    letter-spacing: -0.005em;
}

.card-accent {
    color: var(--c-bubble);
    text-shadow: 0 0 10px rgba(122, 176, 200, 0.25);
}

.card-desc {
    color: var(--c-shade);
    font-size: 15px;
    margin-bottom: 18px;
    font-variation-settings: "MONO" 0, "CASL" 0.6;
}

.card-tape {
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        var(--c-amber-soft),
        transparent
    );
    margin: 14px 0;
    opacity: 0.6;
}

.card-action {
    background: transparent;
    border: 1px solid var(--c-bronze);
    color: var(--c-shade);
    padding: 8px 14px;
    border-radius: 4px;
    font-family: var(--f-rec);
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 500;
    font-size: 12px;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 250ms, color 250ms, border-color 250ms;
}

.card-action:hover {
    background: var(--c-term-dark);
    color: var(--c-amber);
    border-color: var(--c-term-dark);
}

/* Readme panel — collapsible terminal-styled drawer */
.readme-panel {
    margin-top: 26px;
    background: var(--c-term-dark);
    border-radius: 10px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 500ms var(--ease-soft), opacity 350ms;
    box-shadow: 0 10px 30px rgba(42, 36, 24, 0.18);
}

.readme-panel.open {
    max-height: 600px;
    opacity: 1;
}

.readme-head {
    background: var(--c-term-darker);
    padding: 10px 18px;
    color: var(--c-warm-gray);
    font-variation-settings: "MONO" 1;
    font-size: 13px;
    border-bottom: 1px solid rgba(212, 168, 75, 0.07);
    display: flex;
    gap: 8px;
}

.readme-prompt { color: var(--c-bubble); }
.readme-cmd    { color: var(--c-paper-light); }

.readme-body {
    padding: 22px 26px;
    color: var(--c-amber);
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 400;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    text-shadow: 0 0 4px rgba(212, 168, 75, 0.15);
    min-height: 120px;
    max-height: 460px;
    overflow-y: auto;
}

.readme-close {
    background: transparent;
    border: none;
    color: var(--c-warm-gray);
    font-family: var(--f-rec);
    font-variation-settings: "MONO" 1;
    font-size: 11px;
    padding: 8px 18px 14px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: color 200ms;
    width: 100%;
    text-align: right;
}

.readme-close:hover { color: var(--c-amber); }

/* =============================================================
   Notes section — vertical stream
   ============================================================= */

.note-stream {
    list-style: none;
    margin-top: 12px;
    border-left: 1px dashed var(--c-bronze);
    padding-left: 28px;
    max-width: 70ch;
}

.note {
    position: relative;
    padding: 16px 0 16px 0;
    border-bottom: 1px dashed var(--c-paper-band);
}

.note:last-child { border-bottom: none; }

.note::before {
    content: "";
    position: absolute;
    left: -34px;
    top: 24px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--c-amber);
    box-shadow: 0 0 0 4px var(--c-paper), 0 0 8px rgba(212, 168, 75, 0.4);
}

.note-time {
    color: var(--c-amber-soft);
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 600;
    font-size: 13px;
    letter-spacing: 0.04em;
    display: inline-block;
    margin-bottom: 6px;
}

.note p {
    color: var(--c-shade);
    font-size: 16px;
    font-variation-settings: "MONO" 0, "CASL" 0.6;
}

.note code {
    background: var(--c-paper-band);
    color: var(--c-term-dark);
    padding: 2px 6px;
    border-radius: 3px;
    font-variation-settings: "MONO" 1, "CASL" 0;
    font-size: 0.9em;
}

/* =============================================================
   Sign-off
   ============================================================= */

.section-signoff { padding-bottom: 60px; }

.signoff-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-top: 26px;
    margin-bottom: 36px;
}

.signoff-link {
    color: var(--c-term-dark);
    text-decoration: none;
    font-variation-settings: "MONO" 1, "CASL" 0, "wght" 500;
    font-size: clamp(16px, 1.4vw, 22px);
    padding: 10px 16px;
    border: 1px solid var(--c-bronze);
    border-radius: 4px;
    background: var(--c-paper-light);
    transition: background 250ms, color 250ms, border-color 250ms, transform 250ms;
    letter-spacing: 0.02em;
}

.signoff-link:hover {
    background: var(--c-term-dark);
    color: var(--c-amber);
    border-color: var(--c-term-dark);
    transform: translateY(-1px);
}

.link-glyph {
    color: var(--c-amber-soft);
    margin-right: 1px;
}

.link-sep {
    color: var(--c-bubble);
    margin: 0 2px;
}

.signoff-divider {
    color: var(--c-warm-gray);
    font-size: 18px;
}

.signoff-ascii {
    color: var(--c-bronze);
    font-variation-settings: "MONO" 1, "wght" 500;
    font-size: 12px;
    line-height: 1.2;
    margin-top: 14px;
    opacity: 0.75;
    white-space: pre;
    overflow-x: auto;
}

/* =============================================================
   Footer
   ============================================================= */

.page-footer {
    text-align: center;
    padding: 42px 6vw 60px;
    color: var(--c-warm-gray);
    font-variation-settings: "MONO" 1, "CASL" 0;
    font-size: 12px;
    letter-spacing: 0.04em;
    z-index: 3;
    position: relative;
}

.footer-mark { display: inline-block; }
.footer-sep  { margin: 0 12px; opacity: 0.5; }

.page-footer code {
    background: var(--c-paper-band);
    color: var(--c-term-dark);
    padding: 1px 5px;
    border-radius: 3px;
}

/* =============================================================
   Responsive
   ============================================================= */

@media (max-width: 880px) {
    .terminal {
        width: 90vw;
        height: 78vh;
        min-height: 460px;
    }
    .terminal-body { padding: 18px 18px; }
    .ascii-logo { font-size: 7px; }
    .section { padding: 70px 6vw; }
    .skeleton-overlay { inset: 70px 6vw 70px 6vw; }
    .skel-grid { grid-template-columns: 1fr; }
    .title { font-size: 11px; }
    .terminal-footer { font-size: 10px; padding: 6px 12px; }
}

@media (max-width: 540px) {
    .terminal { height: 82vh; }
    .ascii-logo { font-size: 5.5px; }
    .hero-marquee { font-size: 11px; }
    .signoff-actions { flex-direction: column; align-items: flex-start; }
    .signoff-divider { display: none; }
}
