/* ============================================================
   hinagiku.date — Dark Academia · Art Deco Tokyo · Bento Grid
   Colors: #17120A #E8DFC8 #C9A84C #2C1F0E #8B5A2B #6B7B6E #D4B8A0 #3D2E1A
   ============================================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #17120A;
    color: #E8DFC8;
}

/* ---- Viewport wrapper — clips corners of the tilted grid ---- */
#viewport-wrapper {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #17120A;
    display: flex;
    flex-direction: column;
}

/* ---- Bento Grid — 1.5° clockwise tilt ---- */
#bento-grid {
    position: absolute;
    inset: -4vw;           /* extra room so rotated corners don't show */
    display: flex;
    flex-direction: column;
    transform: rotate(1.5deg);
    transform-origin: center center;
    gap: 4px;
    padding: 4px;
}

/* ---- Sequential cell fade-in ---- */
.cell-hidden {
    opacity: 0;
}
.cell-visible {
    opacity: 1;
    transition: opacity 400ms ease;
}

/* ---- Header Band ---- */
#site-header {
    height: 80px;
    min-height: 80px;
    flex-shrink: 0;
    background: #17120A;
    border-bottom: 1px solid #3D2E1A;
    display: flex;
    align-items: center;
    padding: 0 clamp(24px, 4vw, 64px);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
}

.site-name-jp {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 900;
    font-size: clamp(28px, 3vw, 42px);
    color: #C9A84C;
    letter-spacing: -0.03em;
}

.header-rule-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, #3D2E1A, #C9A84C, #3D2E1A);
}

.site-sub {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.18em;
    color: #6B7B6E;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---- Main Content Area ---- */
#main-content {
    flex: 1;
    display: flex;
    gap: 4px;
    overflow: hidden;
    min-height: 0;
}

/* ---- Bento Cell Base ---- */
.bento-cell {
    position: relative;
    border: 1px solid #3D2E1A;
    overflow: hidden;
    flex-shrink: 0;
}

/* ---- Hero Cell ---- */
#hero-cell {
    flex: 7;
    background: #E8DFC8;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(24px, 4vw, 64px);
}

/* Aged paper texture — CSS/SVG only, no external images */
#paper-texture {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 10% 15%, rgba(139, 90, 43, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 40% 40% at 90% 85%, rgba(61, 46, 26, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 60% 50% at 50% 50%, rgba(232, 223, 200, 0.95) 0%, rgba(212, 184, 160, 0.3) 100%);
    filter: url(#paper-grain);
    mix-blend-mode: multiply;
    opacity: 0.9;
}

/* ---- Corner Brackets ---- */
.corner-bracket {
    position: absolute;
    width: 20px;
    height: 20px;
    z-index: 10;
}
.corner-tl { top: 6px; left: 6px; }
.corner-tr { top: 6px; right: 6px; }
.corner-bl { bottom: 6px; left: 6px; }
.corner-br { bottom: 6px; right: 6px; }

/* The hero cell brackets are drawn last — SVG stroke animation */
#hero-cell .corner-bracket path {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
}
#hero-cell .corner-bracket.bracket-drawn path {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 300ms ease;
}

/* ---- Hero Date Display ---- */
#hero-date-display {
    position: relative;
    z-index: 2;
    width: 100%;
}

.japanese-date-text {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 900;
    font-size: clamp(32px, 5.5vw, 72px);
    color: #17120A;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 16px;
    white-space: nowrap;
}

.rule-divider-svg {
    display: block;
    width: 100%;
    height: 8px;
    margin: 12px 0;
}

.roman-date-text {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: clamp(13px, 1.5vw, 20px);
    letter-spacing: 0.18em;
    color: #2C1F0E;
    margin-top: 4px;
    margin-bottom: 8px;
}

.live-clock-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(28px, 4vw, 56px);
    color: #C9A84C;
    letter-spacing: 0.04em;
    margin-top: 16px;
    transition: color 200ms ease;
}

.live-clock-text.pulse {
    color: #E8DFC8;
}

.day-label-text {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: clamp(11px, 1.2vw, 16px);
    letter-spacing: 0.18em;
    color: #6B7B6E;
    margin-top: 8px;
    text-transform: uppercase;
}

/* ---- Hero Footer ---- */
#hero-footer {
    position: absolute;
    bottom: clamp(16px, 3vw, 40px);
    left: clamp(24px, 4vw, 64px);
    right: clamp(24px, 4vw, 64px);
    z-index: 2;
}

.hero-annotation {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.22em;
    color: #8B5A2B;
    text-transform: uppercase;
    margin-top: 6px;
}

/* ---- Right Column ---- */
#right-column {
    flex: 5;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---- Right Upper ---- */
#right-upper {
    flex: 55;
    background: #1a1208;
    border: 1px solid #3D2E1A;
    padding: clamp(16px, 2.5vw, 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ---- Right Lower ---- */
#right-lower {
    flex: 45;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}

/* Sub-cells */
.subcell {
    flex: 1;
    background: #2C1F0E;
    border: 1px solid #3D2E1A;
    padding: clamp(10px, 1.8vw, 24px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    overflow: hidden;
}

/* ---- Cell Labels ---- */
.cell-label {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.18em;
    color: #C9A84C;
    text-transform: uppercase;
    margin-bottom: 8px;
    flex-shrink: 0;
}

/* ---- Vertical Almanac Panel ---- */
#vertical-almanac {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.vertical-text-panel {
    display: flex;
    flex-direction: row;
    gap: 16px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: 100%;
    align-items: flex-start;
}

.vertical-text-panel span {
    font-family: 'Noto Serif JP', serif;
    font-weight: 400;
    font-size: clamp(13px, 1.4vw, 18px);
    color: #E8DFC8;
    letter-spacing: 0.08em;
    line-height: 1.6;
}

#almanac-season {
    color: #C9A84C;
    font-size: clamp(14px, 1.6vw, 20px);
}

#almanac-solar-term {
    color: #D4B8A0;
}

#almanac-rokuyo {
    color: #6B7B6E;
    font-size: clamp(11px, 1.1vw, 14px);
}

#almanac-lunar {
    color: #8B5A2B;
    font-size: clamp(11px, 1.1vw, 14px);
}

/* ---- Bloom Countdown Sub-cell ---- */
#subcell-bloom {
    position: relative;
}

#pheno-grid {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.4;
    pointer-events: none;
}

.bloom-data {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(14px, 1.8vw, 22px);
    color: #C9A84C;
    margin-top: 4px;
    position: relative;
    z-index: 2;
}

.bloom-annotation {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: 9px;
    letter-spacing: 0.18em;
    color: #6B7B6E;
    position: absolute;
    bottom: 8px;
    left: clamp(10px, 1.8vw, 24px);
    z-index: 2;
    text-transform: uppercase;
}

/* ---- Moon Phase Sub-cell ---- */
#subcell-moon {
    align-items: flex-start;
}

#moon-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

#moon-phase-svg {
    width: clamp(40px, 5vw, 72px);
    height: clamp(40px, 5vw, 72px);
    flex-shrink: 0;
}

.moon-data {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(11px, 1.1vw, 14px);
    color: #D4B8A0;
    line-height: 1.5;
}

/* ---- Poetry Sub-cell ---- */
#subcell-poem {
    position: relative;
}

.hinagiku-watermark-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.15;
    pointer-events: none;
}

#poem-container {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.poem-waka {
    font-family: 'Noto Serif JP', serif;
    font-weight: 400;
    font-size: clamp(11px, 1.2vw, 15px);
    color: #E8DFC8;
    line-height: 1.8;
    letter-spacing: 0.04em;
    transition: opacity 600ms ease;
}

.poem-attribution {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: 9px;
    letter-spacing: 0.18em;
    color: #6B7B6E;
    margin-top: 6px;
    text-transform: uppercase;
    transition: opacity 600ms ease;
}

.poem-fade-out {
    opacity: 0;
}

.poem-fade-in {
    opacity: 1;
}

/* ---- Footer Band ---- */
#site-footer {
    height: 80px;
    min-height: 80px;
    flex-shrink: 0;
    background: #17120A;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.footer-rule-top,
.footer-rule-bottom {
    height: 1px;
    background: linear-gradient(to right, #17120A, #3D2E1A, #C9A84C, #3D2E1A, #17120A);
    margin: 0 clamp(24px, 4vw, 64px);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px clamp(24px, 4vw, 64px);
    flex: 1;
}

.footer-left,
.footer-center,
.footer-right {
    font-family: 'Cormorant SC', serif;
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.18em;
    color: #6B7B6E;
    text-transform: uppercase;
}

.footer-center {
    color: #C9A84C;
}

/* ============================================================
   MOBILE — stack bento cells vertically
   ============================================================ */
@media (max-width: 768px) {
    html, body {
        overflow: auto;
    }

    #viewport-wrapper {
        position: relative;
        overflow: visible;
        height: auto;
        min-height: 100vh;
    }

    #bento-grid {
        position: relative;
        inset: auto;
        transform: none;   /* remove tilt on mobile */
        padding: 8px;
        gap: 8px;
    }

    #main-content {
        flex-direction: column;
        overflow: visible;
    }

    #hero-cell {
        flex: none;
        min-height: 60vh;
    }

    #right-column {
        flex: none;
    }

    #right-upper {
        flex: none;
        min-height: 200px;
    }

    #right-lower {
        flex: none;
        min-height: 400px;
    }

    .subcell {
        min-height: 120px;
    }

    .vertical-text-panel {
        flex-direction: row;
        writing-mode: horizontal-tb;
        height: auto;
    }

    .vertical-text-panel span {
        writing-mode: horizontal-tb;
    }

    .japanese-date-text {
        font-size: 32px;
        white-space: normal;
    }

    .live-clock-text {
        font-size: 28px;
    }
}
