/* ============================================
   heisei.day — Heisei Era Cultural Dashboard
   Colors: #5A7A8A, #8AA0A4, #A0B4A8, #1A2428,
           #F0F4F2, #D04040, #2A3438
   Fonts: Share Tech Mono, Noto Sans JP
   ============================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 400;
    line-height: 1.75;
    font-size: clamp(14px, 1vw, 16px);
    color: #2A3438;
    background: #F0F4F2;
}

/* ----- Utility ----- */
.jp-text {
    font-family: 'Noto Sans JP', sans-serif;
}

.hidden {
    display: none !important;
}

/* ============================================
   TOP BAR
   ============================================ */
#top-bar {
    height: 56px;
    background: linear-gradient(90deg, #5A7A8A, #8AA0A4, #A0B4A8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: relative;
    z-index: 100;
}

#logotype {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(14px, 1.1vw, 18px);
    letter-spacing: 0.06em;
    color: #F0F4F2;
    text-transform: lowercase;
}

#date-selector {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(12px, 0.9vw, 15px);
    letter-spacing: 0.06em;
    color: #F0F4F2;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    user-select: none;
}

#date-display {
    pointer-events: none;
}

#date-arrow {
    transition: transform 0.2s ease;
}

#date-selector.open #date-arrow {
    transform: rotate(180deg);
}

/* Calendar Dropdown */
#calendar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1A2428;
    border: 1px solid rgba(90, 122, 138, 0.6);
    padding: 16px;
    z-index: 200;
    width: 280px;
    font-family: 'Share Tech Mono', monospace;
    color: #F0F4F2;
}

#calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
    letter-spacing: 0.06em;
}

#calendar-header button {
    background: none;
    border: 1px solid rgba(90, 122, 138, 0.4);
    color: #F0F4F2;
    font-family: 'Share Tech Mono', monospace;
    cursor: pointer;
    padding: 2px 8px;
    font-size: 12px;
    transition: border-color 0.2s ease;
}

#calendar-header button:hover {
    border-color: #8AA0A4;
}

#calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.1em;
    color: #8AA0A4;
    margin-bottom: 8px;
}

#calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

#calendar-days span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

#calendar-days span:hover {
    background: rgba(138, 160, 164, 0.2);
}

#calendar-days span.today {
    border: 1px solid #D04040;
    color: #D04040;
}

#calendar-days span.selected {
    background: #5A7A8A;
    color: #F0F4F2;
}

#calendar-days span.other-month {
    color: rgba(240, 244, 242, 0.25);
}

#era-indicator {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(12px, 0.9vw, 15px);
    letter-spacing: 0.06em;
    color: #F0F4F2;
}

#era-indicator .jp-text {
    font-weight: 700;
    font-size: clamp(14px, 1.1vw, 18px);
    margin-left: 6px;
}

/* ============================================
   DASHBOARD GRID
   ============================================ */
#dashboard {
    height: calc(100vh - 56px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
    padding: 1px;
    background: rgba(90, 122, 138, 0.1);
}

/* ----- Panel Base ----- */
.panel {
    background: #F0F4F2;
    border: 1px solid rgba(90, 122, 138, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: border-color 0.2s ease;
}

.panel:hover {
    border-color: rgba(90, 122, 138, 0.8);
}

.panel:hover .panel-content {
    transform: scale(1.02);
}

.panel-wide {
    grid-column: span 2;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(90, 122, 138, 0.2);
    flex-shrink: 0;
}

.panel-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(10px, 0.75vw, 12px);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #5A7A8A;
}

.panel-timestamp {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(10px, 0.7vw, 11px);
    letter-spacing: 0.06em;
    color: #8AA0A4;
}

.panel-content {
    flex: 1;
    padding: 16px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    transform-origin: center center;
}

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

/* ============================================
   PANEL 1: TODAY IN HEISEI
   ============================================ */
#today-content {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

#today-photo {
    position: relative;
    width: 45%;
    min-height: 100%;
    background: #2A3438;
    overflow: hidden;
    flex-shrink: 0;
}

#today-photo-overlay {
    position: absolute;
    inset: 0;
    background: #5A7A8A;
    opacity: 0.4;
    mix-blend-mode: overlay;
    z-index: 2;
}

#today-photo-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: grayscale(1) contrast(1.1) brightness(0.9);
    z-index: 1;
}

#today-photo-placeholder svg {
    width: 100%;
    height: 100%;
}

#today-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

#today-year {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: clamp(20px, 2vw, 32px);
    color: #5A7A8A;
    line-height: 1.2;
}

#today-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(13px, 1vw, 16px);
    letter-spacing: 0.04em;
    color: #2A3438;
    line-height: 1.4;
}

#today-description {
    font-size: clamp(12px, 0.85vw, 14px);
    color: #5A7A8A;
    line-height: 1.6;
}

/* Photo zoom-out animation */
@keyframes photoZoomOut {
    from {
        transform: scale(1.05);
        opacity: 0;
    }
    to {
        transform: scale(1.0);
        opacity: 1;
    }
}

#today-photo.animate {
    animation: photoZoomOut 0.8s ease-out forwards;
}

/* ============================================
   PANEL 2: CULTURAL PULSE
   ============================================ */
#pulse-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#pulse-graph {
    flex: 1;
    position: relative;
    min-height: 0;
}

#pulse-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#pulse-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #D04040;
    top: 50%;
    right: 16px;
    transform: translate(50%, -50%);
    z-index: 5;
}

#pulse-dot-ring {
    position: absolute;
    inset: -6px;
    border: 2px solid #D04040;
    animation: pulseRing 1.5s ease-out infinite;
}

@keyframes pulseRing {
    0% {
        transform: scale(1.0);
        opacity: 1;
    }
    100% {
        transform: scale(2.0);
        opacity: 0;
    }
}

#pulse-value {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

#pulse-number {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(22px, 2vw, 32px);
    color: #2A3438;
    letter-spacing: 0.02em;
}

#pulse-unit {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(10px, 0.7vw, 12px);
    color: #8AA0A4;
    letter-spacing: 0.06em;
}

/* ============================================
   PANEL 3: WORD OF THE DAY
   ============================================ */
#word-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#word-brackets {
    position: relative;
    padding: 20px 16px;
    text-align: center;
}

/* Sharp-angled decorative brackets */
.bracket {
    position: absolute;
    width: 16px;
    height: 16px;
}

.bracket-top-left {
    top: 0;
    left: 0;
    border-top: 2px solid #5A7A8A;
    border-left: 2px solid #5A7A8A;
}

.bracket-top-right {
    top: 0;
    right: 0;
    border-top: 2px solid #5A7A8A;
    border-right: 2px solid #5A7A8A;
}

.bracket-bottom-left {
    bottom: 0;
    left: 0;
    border-bottom: 2px solid #5A7A8A;
    border-left: 2px solid #5A7A8A;
}

.bracket-bottom-right {
    bottom: 0;
    right: 0;
    border-bottom: 2px solid #5A7A8A;
    border-right: 2px solid #5A7A8A;
}

#word-main {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: clamp(22px, 2.2vw, 36px);
    color: #2A3438;
    line-height: 1.3;
}

#word-reading {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(11px, 0.8vw, 13px);
    color: #8AA0A4;
    letter-spacing: 0.08em;
    margin-top: 4px;
}

#word-definition {
    font-size: clamp(12px, 0.85vw, 14px);
    color: #2A3438;
    line-height: 1.6;
    padding: 0 4px;
}

#word-usage {
    border-top: 1px solid rgba(90, 122, 138, 0.2);
    padding-top: 8px;
}

#word-usage-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8AA0A4;
    display: block;
    margin-bottom: 4px;
}

#word-usage-text {
    font-size: clamp(11px, 0.8vw, 13px);
    color: #5A7A8A;
    font-style: italic;
    line-height: 1.5;
}

/* ============================================
   PANEL 4: SOUND
   ============================================ */
#sound-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#waveform {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 60px;
    flex: 1;
    width: 100%;
    padding: 0 8px;
}

.wave-bar {
    width: 2px;
    background: #8AA0A4;
    animation: waveOscillate 1.2s ease-in-out infinite alternate;
    transform-origin: bottom;
}

@keyframes waveOscillate {
    0% {
        transform: scaleY(1);
    }
    100% {
        transform: scaleY(0.4);
    }
}

#sound-name {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(12px, 0.9vw, 14px);
    color: #2A3438;
    letter-spacing: 0.04em;
    text-align: center;
}

#sound-description {
    font-size: clamp(11px, 0.75vw, 12px);
    color: #8AA0A4;
    text-align: center;
    line-height: 1.5;
}

/* ============================================
   PANEL 5: COLOR
   ============================================ */
#color-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#color-swatch {
    flex: 1;
    min-height: 60px;
    border: 1px solid rgba(90, 122, 138, 0.15);
}

#color-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#color-name {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 700;
    font-size: clamp(16px, 1.4vw, 22px);
    color: #2A3438;
}

#color-romaji {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(11px, 0.8vw, 13px);
    color: #8AA0A4;
    letter-spacing: 0.06em;
}

#color-significance {
    font-size: clamp(11px, 0.75vw, 12px);
    color: #5A7A8A;
    line-height: 1.5;
}

/* ============================================
   PANEL 6: COUNTDOWN
   ============================================ */
#countdown-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

#countdown-number {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#countdown-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(36px, 4vw, 64px);
    color: #2A3438;
    letter-spacing: 0.02em;
    line-height: 1;
}

#countdown-pulse-ring {
    position: absolute;
    inset: -12px;
    border: 2px solid #D04040;
    animation: pulseRing 1.5s ease-out infinite;
    pointer-events: none;
}

#countdown-unit {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(11px, 0.8vw, 13px);
    color: #8AA0A4;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

#countdown-date {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(10px, 0.7vw, 11px);
    color: rgba(90, 122, 138, 0.6);
    letter-spacing: 0.06em;
    margin-top: 8px;
}

/* Burst animation for click */
@keyframes burstRing {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

.burst-ring {
    position: absolute;
    inset: -12px;
    border: 2px solid #D04040;
    pointer-events: none;
    animation: burstRing 0.5s ease-out forwards;
}

/* ============================================
   BOOT-UP SEQUENCE ANIMATION
   ============================================ */
.panel {
    opacity: 0;
    animation: panelAppear 0.3s ease-out forwards;
}

@keyframes panelAppear {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#panel-today    { animation-delay: 0ms; }
#panel-pulse    { animation-delay: 200ms; }
#panel-word     { animation-delay: 400ms; }
#panel-sound    { animation-delay: 600ms; }
#panel-color    { animation-delay: 800ms; }
#panel-countdown { animation-delay: 1000ms; }

/* ============================================
   PANEL CROSS-FADE TRANSITION
   ============================================ */
.panel-content.cross-fade-out {
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.panel-content.cross-fade-in {
    opacity: 1;
    transition: opacity 0.15s ease-in;
}

/* ============================================
   RESPONSIVE (MOBILE FALLBACK)
   ============================================ */
@media (max-width: 768px) {
    #dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        height: auto;
        overflow-y: auto;
    }

    .panel-wide {
        grid-column: span 1;
    }

    .panel {
        min-height: 200px;
    }

    #today-content {
        flex-direction: column;
    }

    #today-photo {
        width: 100%;
        min-height: 150px;
    }

    body {
        overflow: auto;
    }
}
