/* ============================================================
   rinji.dev — Dark-Mode Navy-Metallic Laboratory
   Colors: #0C1420, #141E2C, #E8F0F8, #A0B0C0, #5078A8, #508060, #3060A0
   Font: JetBrains Mono (300, 400, 700)
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #3060A0 #0C1420;
}

body {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    line-height: 1.9;
    color: #A0B0C0;
    background-color: #0C1420;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::-webkit-scrollbar {
    width: 6px;
}

body::-webkit-scrollbar-track {
    background: #0C1420;
}

body::-webkit-scrollbar-thumb {
    background: #3060A0;
    border-radius: 3px;
}

/* --- Animations --- */
@keyframes labPulse {
    0%, 100% {
        border-color: #141E2C;
    }
    25% {
        border-color: #3060A0;
    }
    50% {
        border-color: #5078A8;
    }
    75% {
        border-color: #3060A0;
    }
}

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

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

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

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes hudScan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes breathe {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.005);
    }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes botanicalSway {
    0%, 100% {
        transform: rotate(0deg) translateY(0);
    }
    25% {
        transform: rotate(0.5deg) translateY(-2px);
    }
    75% {
        transform: rotate(-0.5deg) translateY(2px);
    }
}

@keyframes hudGlitch {
    0%, 95%, 100% { opacity: 0.08; }
    96% { opacity: 0.2; }
    97% { opacity: 0.05; }
    98% { opacity: 0.15; }
}

/* --- HUD Corner Brackets --- */
.hud-corner {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    animation: fadeIn 1.5s ease-out 0.5s both;
}

.hud-top-left {
    top: 12px;
    left: 12px;
}

.hud-top-right {
    top: 12px;
    right: 12px;
}

.hud-bottom-left {
    bottom: 12px;
    left: 12px;
}

.hud-bottom-right {
    bottom: 12px;
    right: 12px;
}

.hud-corner svg {
    animation: hudGlitch 8s ease-in-out infinite;
}

/* --- HUD Status Bars --- */
.hud-status-bar {
    position: fixed;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 6px 80px;
    z-index: 90;
    background: rgba(12, 20, 32, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-color: rgba(80, 120, 168, 0.06);
    animation: fadeIn 1s ease-out 0.3s both;
}

.hud-status-top {
    top: 0;
    border-bottom: 1px solid rgba(80, 120, 168, 0.06);
}

.hud-status-bottom {
    bottom: 0;
    border-top: 1px solid rgba(80, 120, 168, 0.06);
}

.hud-label {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: #5078A8;
    text-transform: uppercase;
}

.hud-separator {
    width: 1px;
    height: 10px;
    background: rgba(80, 120, 168, 0.15);
}

.hud-clock {
    min-width: 6ch;
    text-align: center;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, rgba(48, 96, 160, 0.06) 0%, transparent 60%),
                #0C1420;
}

/* --- Botanical Illustrations --- */
.botanical {
    position: absolute;
    pointer-events: none;
    animation: botanicalSway 12s ease-in-out infinite;
}

.botanical-fern-1 {
    top: 8%;
    left: 5%;
    width: 180px;
    opacity: 1;
    animation-delay: 0s;
}

.botanical-fern-2 {
    bottom: 10%;
    right: 6%;
    width: 150px;
    opacity: 1;
    animation-delay: -4s;
}

.botanical-moss {
    bottom: 20%;
    left: 10%;
    width: 280px;
    opacity: 1;
    animation-delay: -8s;
}

.botanical-lichen {
    top: 15%;
    right: 12%;
    width: 140px;
    opacity: 1;
    animation-delay: -6s;
}

/* --- Hero Content --- */
.hero-content {
    text-align: center;
    z-index: 10;
    animation: fadeInUp 1.2s ease-out 0.2s both;
}

.hero-title-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hero-title {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: clamp(2.4rem, 6vw, 4.2rem);
    color: #E8F0F8;
    letter-spacing: 0.15em;
    line-height: 1.1;
    text-shadow: 0 0 40px rgba(48, 96, 160, 0.15),
                 0 0 80px rgba(48, 96, 160, 0.05);
}

.hero-cursor {
    width: 3px;
    height: clamp(2rem, 5vw, 3.5rem);
    background: #3060A0;
    margin-left: 8px;
    animation: cursorBlink 1s step-end infinite;
}

.hero-subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: #5078A8;
    letter-spacing: 0.2em;
    margin-top: 20px;
    text-transform: lowercase;
}

.hero-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 32px;
    animation: fadeIn 1s ease-out 1.2s both;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #508060;
    animation: statusPulse 2s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(80, 128, 96, 0.4);
}

.status-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: #5078A8;
    letter-spacing: 0.15em;
}

/* --- HUD Readouts --- */
.hud-readout {
    position: absolute;
    bottom: 60px;
    z-index: 10;
    width: 120px;
    animation: fadeIn 1.2s ease-out 1.5s both;
}

.hud-readout-left {
    left: 30px;
    animation-name: slideInLeft;
    animation-duration: 1s;
    animation-delay: 1.5s;
    animation-fill-mode: both;
}

.hud-readout-right {
    right: 30px;
    text-align: right;
    animation-name: slideInRight;
    animation-duration: 1s;
    animation-delay: 1.5s;
    animation-fill-mode: both;
}

.readout-label {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.6rem;
    color: #5078A8;
    letter-spacing: 0.15em;
    margin-bottom: 4px;
}

.readout-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: #A0B0C0;
    margin-bottom: 6px;
}

.readout-bar {
    height: 2px;
    background: rgba(80, 120, 168, 0.12);
    border-radius: 1px;
    overflow: hidden;
}

.readout-bar-fill {
    height: 100%;
    background: #3060A0;
    border-radius: 1px;
    transition: width 0.3s ease-out;
    width: 0%;
}

/* --- Lab Sections --- */
.lab-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 24px;
    position: relative;
}

.lab-section.visible .lab-container,
.lab-section.visible .section-label,
.lab-section.visible .organic-flow-grid {
    opacity: 1;
    transform: translateY(0);
}

/* --- Section Label --- */
.section-label {
    text-align: center;
    margin-bottom: 32px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

/* --- Organic Containers --- */
.lab-container {
    position: relative;
    padding: 36px 32px;
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.organic-container {
    background: #141E2C;
    border: 1px solid rgba(80, 120, 168, 0.08);
    animation: breathe 6s ease-in-out infinite;
}

/* Organic border-radius variants */
.organic-1 {
    border-radius: 30% 70% 60% 40% / 50% 30% 70% 50%;
    padding: 48px 40px;
}

.organic-2 {
    border-radius: 60% 40% 50% 50% / 40% 60% 40% 60%;
}

.organic-3 {
    border-radius: 40% 60% 70% 30% / 55% 35% 65% 45%;
}

.organic-4 {
    border-radius: 50% 50% 40% 60% / 35% 65% 35% 65%;
}

.organic-5 {
    border-radius: 35% 65% 55% 45% / 60% 40% 55% 45%;
}

.organic-6 {
    border-radius: 45% 55% 50% 50% / 45% 55% 50% 50%;
    padding: 32px 24px;
}

.organic-7 {
    border-radius: 55% 45% 60% 40% / 50% 50% 45% 55%;
    padding: 40px 36px;
}

.organic-8 {
    border-radius: 40% 60% 45% 55% / 55% 45% 60% 40%;
    padding: 44px 36px;
}

/* Container HUD Frame */
.container-hud-frame {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: inherit;
}

.hud-frame-svg {
    width: 100%;
    height: 100%;
}

/* --- Pulse Border Animation --- */
.pulse-border {
    animation: labPulse 2s ease-in-out infinite, breathe 6s ease-in-out infinite;
    border-width: 1px;
    border-style: solid;
}

/* Stagger the pulse animation on project cards */
.organic-2.pulse-border { animation-delay: 0s, 0s; }
.organic-3.pulse-border { animation-delay: 0.5s, -1.5s; }
.organic-4.pulse-border { animation-delay: 1s, -3s; }
.organic-5.pulse-border { animation-delay: 1.5s, -4.5s; }

/* --- Lab Labels --- */
.lab-label {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    color: #5078A8;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* --- Lab Headings --- */
.lab-heading {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    color: #E8F0F8;
    letter-spacing: 0.04em;
    margin-bottom: 20px;
    line-height: 1.2;
}

/* --- Lab Text --- */
.lab-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: #A0B0C0;
    line-height: 1.9;
    margin-bottom: 16px;
}

.lab-text:last-child {
    margin-bottom: 0;
}

/* --- Organic Flow Grid (Projects) --- */
.organic-flow-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.organic-flow-grid .lab-container {
    flex: 1 1 calc(50% - 8px);
    min-width: 280px;
    margin-bottom: 0;
}

/* --- Project Cards --- */
.project-index {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 2rem;
    color: rgba(48, 96, 160, 0.15);
    line-height: 1;
    margin-bottom: 12px;
}

.project-title {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    color: #E8F0F8;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.tag {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    color: #5078A8;
    letter-spacing: 0.1em;
    padding: 4px 10px;
    border: 1px solid rgba(80, 120, 168, 0.15);
    border-radius: 20px;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.tag:hover {
    border-color: #3060A0;
    color: #E8F0F8;
}

/* --- Terminal --- */
.terminal-window {
    background: rgba(12, 20, 32, 0.6);
    border: 1px solid rgba(80, 120, 168, 0.1);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 16px;
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(20, 30, 44, 0.8);
    border-bottom: 1px solid rgba(80, 120, 168, 0.06);
}

.terminal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.terminal-dot.red { background: rgba(255, 95, 86, 0.6); }
.terminal-dot.yellow { background: rgba(255, 189, 46, 0.6); }
.terminal-dot.green { background: rgba(39, 201, 63, 0.6); }

.terminal-title {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    color: #5078A8;
    margin-left: 8px;
}

.terminal-body {
    padding: 16px 14px;
    min-height: 120px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.8;
}

.terminal-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.terminal-prompt {
    color: #508060;
    font-weight: 400;
    flex-shrink: 0;
}

.terminal-command {
    color: #E8F0F8;
    font-weight: 400;
}

.terminal-cursor {
    color: #3060A0;
    animation: terminalCursor 0.8s step-end infinite;
    font-weight: 700;
}

.terminal-output {
    color: #5078A8;
    font-weight: 300;
    padding-left: 18px;
    opacity: 0.8;
}

/* --- Status Grid --- */
.status-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(12, 20, 32, 0.4);
    border-radius: 30% 70% 70% 30% / 60% 40% 60% 40%;
    border: 1px solid rgba(80, 120, 168, 0.05);
    transition: border-color 0.4s ease;
}

.status-item:hover {
    border-color: rgba(80, 120, 168, 0.15);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.active {
    background: #508060;
    box-shadow: 0 0 8px rgba(80, 128, 96, 0.4);
    animation: statusPulse 2s ease-in-out infinite;
}

.status-indicator.idle {
    background: #5078A8;
    box-shadow: 0 0 6px rgba(80, 120, 168, 0.3);
    opacity: 0.5;
}

.status-info {
    flex: 1;
}

.status-name {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: #E8F0F8;
    letter-spacing: 0.04em;
}

.status-detail {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: #5078A8;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

/* --- Contact --- */
.contact-links {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: rgba(12, 20, 32, 0.5);
    border: 1px solid rgba(80, 120, 168, 0.1);
    border-radius: 40% 60% 55% 45% / 50% 50% 50% 50%;
    text-decoration: none;
    transition: border-color 0.4s ease, transform 0.3s ease;
}

.contact-link:hover {
    border-color: #3060A0;
    transform: translateY(-2px);
}

.contact-link.pulse-border {
    animation: labPulse 3s ease-in-out infinite;
}

.contact-link:nth-child(2).pulse-border {
    animation-delay: 1s;
}

.contact-icon {
    font-size: 1.1rem;
    color: #5078A8;
    line-height: 1;
}

.contact-link span:last-child {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: #E8F0F8;
    letter-spacing: 0.06em;
}

/* --- Footer --- */
.lab-footer {
    padding: 40px 24px 60px;
    text-align: center;
    border-top: 1px solid rgba(80, 120, 168, 0.06);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: #5078A8;
    letter-spacing: 0.12em;
}

.footer-separator {
    color: rgba(80, 120, 168, 0.2);
    font-size: 0.8rem;
}

/* --- Scroll Reveal Utility --- */
.lab-section .lab-container,
.lab-section .section-label,
.lab-section .organic-flow-grid {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.lab-section.visible .lab-container,
.lab-section.visible .section-label,
.lab-section.visible .organic-flow-grid {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger reveal for flow grid children */
.lab-section.visible .organic-flow-grid .lab-container:nth-child(1) {
    transition-delay: 0.1s;
}
.lab-section.visible .organic-flow-grid .lab-container:nth-child(2) {
    transition-delay: 0.2s;
}
.lab-section.visible .organic-flow-grid .lab-container:nth-child(3) {
    transition-delay: 0.3s;
}
.lab-section.visible .organic-flow-grid .lab-container:nth-child(4) {
    transition-delay: 0.4s;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .organic-flow-grid .lab-container {
        flex: 1 1 100%;
    }

    .hud-readout {
        display: none;
    }

    .hud-status-bar {
        padding: 6px 20px;
        gap: 10px;
    }

    .hero-title {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    .organic-1,
    .organic-6,
    .organic-7,
    .organic-8 {
        padding: 32px 24px;
    }

    .botanical-fern-1 { width: 120px; left: 2%; }
    .botanical-fern-2 { width: 100px; right: 2%; }
    .botanical-moss { width: 200px; }
    .botanical-lichen { width: 100px; }

    .contact-links {
        flex-direction: column;
    }

    .contact-link {
        justify-content: center;
    }
}

@media (max-width: 380px) {
    .hud-status-bar {
        font-size: 0.55rem;
        gap: 6px;
    }

    .hud-label {
        font-size: 0.55rem;
    }
}
