/* ============================================================
   kaihang.dev — "kopi-o" dark theme
   Deep warm charcoal, one Singapore-red accent (also Hack Club
   red), and phosphor for the actual machines.
   ============================================================ */

:root {
    --paper: #151210;
    --paper-2: #1e1a15;
    --paper-3: #282219;

    --ink: #f0e9d9;
    --muted: #9d9480;

    --line: #2e2820;
    --line-strong: #4d4436;

    --accent: #ef3340;         /* singapore red ≈ hack club red */
    --accent-strong: #ff5966;
    --accent-soft: #35161b;

    --green: #43d17a;
    --green-soft: #14351f;
    --red: #ff6b6b;
    --red-soft: #351517;

    --screen: #0d0b08;
    --screen-2: #131008;
    --screen-line: #29241a;
    --screen-text: #dcd6c3;
    --screen-dim: #8a826d;

    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

    --max-width: 1060px;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .32);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
}

/* ---------- reset ---------- */

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

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* A faint red-and-green glow so the page feels lit, not flat. */
.background {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 80% -10%, rgba(239, 51, 64, .09), transparent 55%),
        radial-gradient(ellipse at 10% 110%, rgba(67, 209, 122, .06), transparent 50%);
}

/* ---------- hack club corner flag ---------- */

.hc-flag {
    position: absolute;
    top: 0;
    left: 10px;
    z-index: 999;
    width: 210px;
    border: 0;
    display: block;
    transition: transform .18s ease;
}
.hc-flag:hover { transform: translateY(3px); }
.hc-flag img { display: block; width: 100%; height: auto; }

/* ---------- nav ---------- */

.nav {
    width: min(var(--max-width), calc(100% - 40px));
    height: 72px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
}

.logo {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.02em;
}
.logo span { color: var(--accent); }

.nav nav { display: flex; gap: 22px; }

.nav nav a {
    color: var(--muted);
    font-size: 14px;
    transition: color .15s ease;
}
.nav nav a:hover { color: var(--accent); }

/* ---------- hero ---------- */

.hero {
    width: min(var(--max-width), calc(100% - 40px));
    margin: auto;
    padding: 84px 0 88px;
}

.eyebrow {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.status-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper-2);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

.hero h1 {
    font-family: var(--serif);
    font-size: clamp(56px, 10vw, 116px);
    line-height: .92;
    letter-spacing: -.045em;
    font-weight: 700;
}
.hero h1 span { color: var(--accent); }

.subtitle {
    max-width: 600px;
    margin-top: 22px;
    color: var(--muted);
    font-size: 18px;
}

.subtitle strong { color: var(--ink); font-weight: 600; }

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 30px;
}

.button {
    display: inline-block;
    padding: 11px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); }

.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-strong); }

.button.secondary {
    border: 1px solid var(--line-strong);
    background: var(--paper-2);
    color: var(--ink);
}
.button.secondary:hover { border-color: var(--accent); }

/* ---------- sections ---------- */

.section {
    width: min(var(--max-width), calc(100% - 40px));
    margin: auto;
    padding: 80px 0;
    border-top: 1px solid var(--line);
}

.section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 36px;
}

.section-no {
    display: block;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: .12em;
    margin-bottom: 8px;
}

.section h2 {
    font-family: var(--serif);
    font-size: clamp(36px, 5vw, 56px);
    line-height: 1;
    letter-spacing: -.03em;
    font-weight: 700;
}

.view-all {
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.view-all:hover { text-decoration: underline; }

/* ---------- projects ---------- */

.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.project {
    position: relative;
    min-height: 190px;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper-2);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.project:hover {
    transform: translateY(-3px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
}

.project-name {
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}

.project-description {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
}

.project-meta {
    position: absolute;
    left: 22px;
    bottom: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
}

.language { display: flex; align-items: center; gap: 6px; }
.language-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.project-arrow {
    position: absolute;
    right: 22px;
    bottom: 18px;
    color: var(--accent);
    font-size: 18px;
}

.loading {
    grid-column: 1 / -1;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.loader {
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- about ---------- */

.about-text {
    max-width: 800px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}
.about-text p { color: var(--muted); font-size: 17px; }
.about-text strong { color: var(--ink); font-weight: 600; }

.hackclub-note {
    max-width: 800px;
    margin-top: 32px;
    padding: 14px 18px;
    border-left: 3px solid var(--accent);
    background: var(--paper-2);
    font-size: 15px;
    color: var(--muted);
}
.hackclub-note a { color: var(--accent); font-weight: 600; }
.hackclub-note a:hover { text-decoration: underline; }

/* ---------- stack ---------- */

.stack { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.stack span {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--paper-2);
    font-family: var(--mono);
    font-size: 13px;
    color: var(--ink);
}
.stack span:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- contact ---------- */

.contact-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

.contact-links a {
    padding: 11px 18px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--paper-2);
    font-size: 14px;
    font-weight: 600;
    transition: border-color .15s ease, color .15s ease, transform .15s ease;
}
.contact-links a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ---------- footer ---------- */

footer {
    width: min(var(--max-width), calc(100% - 40px));
    margin: auto;
    padding: 24px 0 32px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

footer .mono { font-family: var(--mono); }

/* ---------- responsive ---------- */

@media (max-width: 800px) {
    .nav { height: 60px; }
    .nav nav { display: none; }

    .hero { padding: 52px 0 56px; }

    .projects-grid { grid-template-columns: 1fr; }
    .about-text { grid-template-columns: 1fr; gap: 20px; }
    .section { padding: 60px 0; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    footer { flex-direction: column; }

    .hc-flag { left: 7px; width: 150px; }
}

@media (max-width: 520px) {
    .hero h1 { font-size: 56px; }
    .subtitle { font-size: 16px; }
    .hc-flag { width: 120px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
