@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Source+Code+Pro:wght@700&display=swap');

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

/* ── remove browser tap/click highlight on all devices ── */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    outline: none;
}

/* restore focus outline for keyboard users only */
:focus-visible {
    outline: 1px solid rgba(255, 100, 0, 0.5);
    outline-offset: 2px;
}

canvas#c {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.ui {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100dvh;
    text-align: center;
    padding: clamp(10px, 3vw, 30px);
    gap: clamp(8px, 2vh, 24px);
}

/* ornament */
.orn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(900px, 96vw);
}

.orn-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #ff3300, transparent);
    opacity: .5;
}

.orn-gem {
    width: 6px;
    height: 6px;
    background: #ff5500;
    transform: rotate(45deg);
    box-shadow: 0 0 8px #ff3300, 0 0 18px rgba(255, 60, 0, .5);
    animation: gpulse 2.2s ease-in-out infinite;
}

@keyframes gpulse {

    0%,
    100% {
        box-shadow: 0 0 8px #ff3300, 0 0 18px rgba(255, 60, 0, .5);
    }

    50% {
        box-shadow: 0 0 14px #ff7700, 0 0 32px rgba(255, 110, 0, .7);
    }
}

/* ── title wrapper ── */
.title-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    /* During animation: generous gap so morse symbols don't overlap */
    gap: var(--lc-gap, clamp(4px, 1.5vw, 14px));
    width: 100%;
    flex-wrap: nowrap;
    transition: gap 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* After reveal: tight gap matching letter spacing */
.title-wrap.revealed {
    gap: var(--lc-gap-revealed, clamp(0px, 0.3vw, 3px));
}

.word-gap {
    width: var(--word-gap, clamp(28px, 6vw, 72px));
    flex-shrink: 0;
    transition: width 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.title-wrap.revealed .word-gap {
    width: var(--word-gap-revealed, clamp(22px, 4.5vw, 56px));
}

/* ── letter cell ── */
/* Width/height sized to the letter itself, not padded */
.lc {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* Size is driven by the letter font-size — no extra padding */
    width: var(--lc-w, clamp(2rem, 6.5vw, 5.6rem));
    height: var(--lc-h, clamp(2.4rem, 7.5vw, 6.4rem));
    /* During animation the morse symbols peek outside — let them */
    overflow: visible;
}

/* All layers absolutely fill the cell */
.lc>* {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── morse symbols layer ── */
.morse-layer {
    gap: clamp(2px, 0.4vw, 5px);
    opacity: 1;
    transition: opacity 0.2s ease;
    /* Allow morse dots/dashes to overflow cell horizontally */
    overflow: visible;
    white-space: nowrap;
}

.md-sym {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s, text-shadow 0.12s;
}

.md-sym.dot {
    font-size: clamp(1.2rem, 2.8vw, 2.4rem);
    color: #ff5500;
}

.md-sym.dash {
    font-size: clamp(1rem, 2.4vw, 2rem);
    color: #ff5500;
}

.md-gap {
    width: clamp(2px, 0.4vw, 6px);
    flex-shrink: 0;
}

/* ── hacker scramble layer ── */
.scramble-layer {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-weight: 700;
    font-size: var(--ltr-size, clamp(1.8rem, 6.5vw, 5.4rem));
    color: #ff3300;
    text-shadow: 0 0 14px rgba(255, 60, 0, .9), 0 0 28px rgba(255, 0, 0, .5);
    opacity: 0;
    transition: opacity 0.08s;
}

@font-face {
    font-family: 'Madu';
    src: url('resources/4u-Madu.ttf') format('truetype');
}

/* ── final Sinhala letter layer ── */
.ltr {
    font-family: Madu;
    font-weight: 200;
    font-size: var(--ltr-size, clamp(1.8rem, 6.5vw, 5.4rem));
    background: linear-gradient(165deg,
            #fff1cc 0%, #ffd580 18%, #ff9500 38%,
            #ff5500 58%, #ff3300 75%, #cc1a00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px rgba(255, 70, 0, .9)) drop-shadow(0 0 28px rgba(255, 30, 0, .65));
    opacity: 0;
    transition: opacity 0.25s ease;
    white-space: nowrap;
}

/* ── tagline ── */
.tagline-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* tall enough to hold the big year number */
    padding-left: clamp(1.3rem, 3.5vw, 2.3rem);
    height: clamp(1.6rem, 3.5vw, 2.8rem);
}

p.tagline {
    display: inline-flex;
    align-items: baseline;
    gap: clamp(6px, 1.2vw, 16px);
    opacity: 0;
    visibility: hidden;
}

p.tagline.crt-typing {
    visibility: visible !important;
    opacity: 1 !important;
}

p.tagline.crt-done {
    visibility: visible !important;
    opacity: 1 !important;
    animation: crtFlicker 4s ease-in-out infinite;
}

/* big bold year — code terminal style */
.tagline-year {
    font-family: 'Source Code Pro', 'Courier New', monospace;
    font-weight: 700;
    font-size: clamp(1.3rem, 2.8vw, 2.3rem);
    letter-spacing: 0.18em;
    color: #ffaa44;
    text-shadow:
        0 0 6px #ff6600,
        0 0 16px rgba(255, 80, 0, .8),
        0 0 32px rgba(255, 30, 0, .4);
}

@keyframes crtFlicker {
    0% {
        opacity: 1;
    }

    8% {
        opacity: .82;
    }

    9% {
        opacity: 1;
    }

    30% {
        opacity: 1;
    }

    31% {
        opacity: .65;
    }

    32% {
        opacity: 1;
    }

    60% {
        opacity: 1;
    }

    61% {
        opacity: .9;
    }

    62% {
        opacity: 1;
    }

    100% {
        opacity: 1;
    }
}

/* cursor sits next to the year, sized to match */
.crt-cursor {
    display: inline-block;
    width: clamp(0.18rem, 0.5vw, 0.4rem);
    height: clamp(0.9rem, 2.4vw, 1.8rem);
    background: #ff8800;
    vertical-align: middle;
    margin-left: clamp(3px, 0.5vw, 8px);
    opacity: 0;
    box-shadow: 0 0 10px rgba(255, 130, 0, .9);
}

.crt-cursor.blink {
    animation: cursorBlink 0.5s step-end infinite;
    opacity: 1;
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.crt-scanline {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, rgba(255, 180, 0, 0.6), transparent);
    opacity: 0;
    pointer-events: none;
    top: 0;
}

.crt-scanline.sweep {
    animation: scanSweep 0.55s linear forwards;
}

@keyframes scanSweep {
    0% {
        top: 0%;
        opacity: 0.9;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

/* ── responsive CSS custom props ── */
/* large desktop */
@media (min-width: 1200px) {
    :root {
        --ltr-size: clamp(4rem, 5.5vw, 5.6rem);
        --lc-w: clamp(3rem, 5.5vw, 5.6rem);
        --lc-h: clamp(3.6rem, 6.5vw, 6.6rem);
        --lc-gap: 12px;
        --lc-gap-revealed: 2px;
        --word-gap: 72px;
        --word-gap-revealed: 56px;
    }
}

/* tablet / laptop */
@media (min-width: 600px) and (max-width: 1199px) {
    :root {
        --ltr-size: clamp(2.6rem, 6vw, 4.8rem);
        --lc-w: clamp(2.6rem, 6vw, 4.8rem);
        --lc-h: clamp(3rem, 7vw, 5.6rem);
        --lc-gap: 8px;
        --lc-gap-revealed: 1px;
        --word-gap: 52px;
        --word-gap-revealed: 40px;
    }
}

/* mobile */
@media (max-width: 599px) {
    :root {
        --ltr-size: clamp(1.6rem, 8vw, 3rem);
        --lc-w: clamp(1.6rem, 8vw, 3rem);
        --lc-h: clamp(2rem, 9.5vw, 3.6rem);
        --lc-gap: 4px;
        --lc-gap-revealed: 0px;
        --word-gap: 32px;
        --word-gap-revealed: 24px;
    }

    .md-sym.dot {
        font-size: clamp(0.8rem, 2.5vw, 1.6rem);
    }

    .md-sym.dash {
        font-size: clamp(0.7rem, 2.2vw, 1.4rem);
    }
}

/* very small phones */
@media (max-width: 380px) {
    :root {
        --ltr-size: clamp(1.4rem, 7.5vw, 2.4rem);
        --lc-w: clamp(1.4rem, 7.5vw, 2.4rem);
        --lc-h: clamp(1.7rem, 9vw, 2.8rem);
        --lc-gap: 2px;
        --lc-gap-revealed: 0px;
        --word-gap: 22px;
        --word-gap-revealed: 16px;
    }
}

/* ════════════════════════════════════
   NAVBAR
════════════════════════════════════ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(16px, 4vw, 48px);
    height: clamp(50px, 7vh, 70px);
    /* ── true glass ── */
    background: rgba(18, 8, 2, 0.28);
    backdrop-filter: blur(24px) saturate(180%) brightness(1.1);
    -webkit-backdrop-filter: blur(24px) saturate(180%) brightness(1.1);
    border-bottom: 1px solid rgba(255, 100, 20, 0.22);
    box-shadow:
        inset 0 1px 0 rgba(255, 140, 40, 0.10),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3),
        0 8px 40px rgba(0, 0, 0, 0.55);
}

/* ── logo ── */
.nav-logo {
    font-family: Madu, serif;
    font-weight: 200;
    font-size: clamp(1.3rem, 2.5vw, 2.3rem);
    background: linear-gradient(135deg, #fff1cc 0%, #ffd580 30%, #ff9500 60%, #ff3300 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 6px rgba(255, 80, 0, .7));
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── nav list ── */
.nav-links {
    display: flex;
    align-items: center;
    /* FIXED gap — every item same distance apart */
    gap: clamp(20px, 3.5vw, 44px);
    list-style: none;
}

.nav-links li a {
    text-decoration: none;
    color: rgba(255, 200, 120, 0.75);
    display: inline-flex;
    align-items: center;
    transition: color 0.2s;
    position: relative;
}

.nav-links li a:hover {
    color: #ffdd99;
}

.nav-links li a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, #ff5500, transparent);
    transform: scaleX(0);
    opacity: 0;
    transition: transform 0.25s, opacity 0.25s;
}

.nav-links li a:hover::after {
    transform: scaleX(1);
    opacity: 1;
}

/* ── each scramble item: flex row of fixed-width char boxes ── */
.nav-scramble {
    display: inline-flex;
    align-items: center;
}

/* every single character slot: same fixed width, monospace */
.nch {
    display: inline-block;
    width: 0.62em;
    /* fixed — every char same column width */
    text-align: center;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(0.7rem, 1.3vw, 0.92rem);
    font-weight: 400;
    line-height: 1;
    color: inherit;
    flex-shrink: 0;
}

/* space slot slightly wider */
.nch.nsp {
    width: 0.38em;
}

/* ── hamburger ── */
.nav-burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 6px;
    background: none;
    border: none;
}

.nav-burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #ff6600;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
    box-shadow: 0 0 6px rgba(255, 80, 0, .6);
}

.nav-burger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-burger.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-burger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ── mobile drawer ── */
@media (max-width: 700px) {
    .nav-burger {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: clamp(50px, 7vh, 70px);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        background: rgba(8, 4, 0, 0.88);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border-bottom: 1px solid rgba(255, 60, 0, 0.15);
        padding: 6px 0 12px;
        transform: translateY(-110%);
        opacity: 0;
        transition: transform 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.32s;
        pointer-events: none;
    }

    .nav-links.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links li a {
        display: flex;
        padding: 13px clamp(20px, 6vw, 36px);
        border-bottom: 1px solid rgba(255, 60, 0, 0.07);
        color: rgba(255, 200, 120, 0.85);
    }

    .nch {
        font-size: clamp(0.9rem, 3.8vw, 1.1rem);
        width: 0.62em;
    }

    .nch.nsp {
        width: 0.38em;
    }
}

/* ── site logo (spinning) ── */
.site-logo-wrap {
    position: fixed;
    /* default: desktop — navbar is ~70px tall, logo sits ~100px below it */
    top: 125px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.site-logo {
    display: block;
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter:
        drop-shadow(0 0 10px rgba(255, 80, 0, 0.85)) drop-shadow(0 0 26px rgba(255, 40, 0, 0.55));
    animation: logoSpin 6s linear infinite;
}

@keyframes logoSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* tablet / laptop  600–1199px */
@media (min-width: 600px) and (max-width: 1199px) {
    .site-logo-wrap {
        top: 120px;
    }

    .site-logo {
        width: 100px;
        height: 100px;
    }
}

/* mobile  ≤ 599px */
@media (max-width: 599px) {
    .site-logo-wrap {
        top: 145px;
    }

    .site-logo {
        width: 72px;
        height: 72px;
    }
}

/* very small phones  ≤ 380px */
@media (max-width: 380px) {
    .site-logo-wrap {
        top: 135px;
    }

    .site-logo {
        width: 66px;
        height: 66px;
    }
}