/* =============================================
   LABORATORIO — Design System
   DevBroken Personal LinkTree
   ============================================= */

/* ---------- Self-hosted Font ---------- */
@font-face {
    font-family: "Fraunces";
    src: url("../fonts/Fraunces.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal italic;
    font-display: swap;
}

/* ---------- Custom Properties ---------- */
:root {
    --maxw: clamp(340px, 90dvw, 680px);
    --radius: 10px;
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --font-mono: "Geist Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace;
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --dur: 0.25s;
    --dur-fast: 0.15s;
}

/* ---------- Dark Theme (default) ---------- */
:root {
    --bg: #0c0a09;
    --surface-1: #151210;
    --surface-2: #1c1815;
    --surface-3: #242019;
    --border: #2a2520;
    --border-hover: #3d3530;
    --text: #e8e0d4;
    --text-2: #9c9284;
    --text-3: #7d7267;
    --accent: #c47a3a;
    --accent-dim: #8b5a2e;
    --accent-text: #d4935a;
    --focus-ring: #c47a3a;
    --grain-opacity: 0.035;
    --vignette-opacity: 0.04;
    --inset-highlight: rgba(255, 255, 255, 0.04);
    --dot-glow: 0 0 8px rgba(196, 122, 58, 0.5);
    color-scheme: dark;
}

/* ---------- Light Theme ---------- */
html[data-theme="light"] {
    --bg: #f5f0e8;
    --surface-1: #ffffff;
    --surface-2: #faf7f2;
    --surface-3: #f0ebe3;
    --border: #e0d8cc;
    --border-hover: #c8bfb0;
    --text: #1a1510;
    --text-2: #5c5347;
    --text-3: #7a7068;
    --accent: #8b5a2e;
    --accent-dim: #c49a6a;
    --accent-text: #7a4f24;
    --focus-ring: #8b5a2e;
    --grain-opacity: 0.02;
    --vignette-opacity: 0.02;
    --inset-highlight: rgba(0, 0, 0, 0.03);
    --dot-glow: 0 0 6px rgba(139, 90, 46, 0.4);
    color-scheme: light;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--dur) ease, color var(--dur) ease;
    overflow-x: hidden;
}

/* ---------- Grain Texture Overlay ---------- */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 180px;
}

/* ---------- Radial Vignette ---------- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(
        ellipse 80% 50% at 50% 0%,
        rgba(196, 122, 58, var(--vignette-opacity)) 0%,
        transparent 70%
    );
}

/* ---------- Selection ---------- */
::selection {
    background: var(--accent);
    color: var(--bg);
}

/* ---------- Focus Ring ---------- */
:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Links ---------- */
a { color: inherit; text-decoration: none; }

/* ---------- Visually Hidden (screen readers only) ---------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Skip Link ---------- */
.skip-link {
    position: fixed;
    left: 1rem;
    top: -3rem;
    background: var(--accent);
    color: var(--bg);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    z-index: 10000;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: top 0.3s var(--spring);
}
.skip-link:focus { top: 1rem; }

/* External link indicator */
[target="_blank"]::after {
    content: " ↗";
    font-size: 0.75em;
    opacity: 0.5;
}

/* =============================================
   LAYOUT
   ============================================= */
.wrap {
    position: relative;
    z-index: 1;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 100px 32px 80px;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    margin-bottom: 72px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border-bottom: 1px solid transparent;
    border-radius: 0 0 8px 8px;
    transition: border-color var(--dur) ease;
}
.site-header.scrolled {
    border-bottom-color: var(--border);
}

.brand {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(0.9rem, 0.82rem + 0.2vw, 1rem);
    letter-spacing: -0.01em;
    color: var(--text);
}
.brand-accent {
    color: var(--accent);
}
/* ---------- Theme Toggle ---------- */
.theme-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 0;
    background: var(--surface-1);
}

.theme-toggle button {
    font-family: var(--font-mono);
    font-size: clamp(0.56rem, 0.5rem + 0.15vw, 0.65rem);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
    background: transparent;
    border: none;
    color: var(--text-3);
    padding: 0.45rem 0.55rem;
    border-radius: 5px;
    cursor: pointer;
    min-width: 24px;
    min-height: 24px;
    transition: color var(--dur-fast) ease, font-weight 0s;
    white-space: nowrap;
}
.theme-toggle button[aria-pressed="true"] {
    color: var(--accent);
    font-weight: 700;
}
.theme-toggle button:hover:not([aria-pressed="true"]) {
    color: var(--text-2);
}

/* =============================================
   HERO
   ============================================= */
.hero {
    margin-bottom: 72px;
}
.eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.58rem, 0.52rem + 0.15vw, 0.65rem);
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 0 0 1rem;
}

h1 {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-weight: 400;
    font-size: clamp(1.65rem, 0.4rem + 4vw, 3.8rem);
    line-height: 1.08;
    letter-spacing: -0.025em;
    margin: 0 0 1rem;
    color: var(--text);
    text-wrap: balance;
}
h1 em {
    font-style: italic;
    font-weight: 400;
    color: var(--accent-text);
}

.tagline {
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 0.72rem + 0.2vw, 0.875rem);
    font-weight: 400;
    color: var(--text-2);
    max-width: 40ch;
    margin: 0;
    line-height: 1.6;
}

/* ---------- Separator ---------- */
.separator {
    display: block;
    width: 100%;
    height: 1px;
    margin: 0 0 56px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--border) 20%,
        var(--border) 80%,
        transparent 100%
    );
    border: none;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: center;
    transition: opacity 0.4s ease, transform 0.4s var(--ease-out);
}
.separator.visible {
    opacity: 1;
    transform: scaleX(1);
}

/* =============================================
   SECTIONS & LINKS
   ============================================= */
section.group {
    margin-bottom: 56px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s var(--ease-out), transform 0.5s var(--spring);
}
section.group.visible {
    opacity: 1;
    transform: translateY(0);
}

.group h2 {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: clamp(0.65rem, 0.59rem + 0.15vw, 0.72rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

ul.links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---------- Link Card ---------- */
.link-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    min-height: 52px;
    position: relative;
    transition:
        background-color var(--dur) ease,
        border-color var(--dur) ease,
        transform var(--dur-fast) ease;
    box-shadow: inset 0 1px 0 var(--inset-highlight);
}

.link-row:hover {
    background: var(--surface-2);
    border-color: var(--border-hover);
}
.link-row:active {
    transform: scale(0.985);
    transition-duration: 0.1s;
}
.link-row:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Visited state */
.link-row.is-visited {
    opacity: 0.7;
}
.link-row.is-visited:hover {
    opacity: 1;
}

/* ---------- Status Dot (square) ---------- */
.status-dot {
    width: 6px;
    height: 6px;
    min-width: 6px;
    border-radius: 2px;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 6px;
    transition: box-shadow var(--dur) ease;
}
.link-row:hover .status-dot {
    box-shadow: var(--dot-glow);
}

/* ---------- Link Body ---------- */
.link-body {
    flex: 1;
    min-width: 0;
}
.link-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-optical-sizing: auto;
    font-size: clamp(0.92rem, 0.82rem + 0.25vw, 1.05rem);
    letter-spacing: -0.01em;
    line-height: 1.3;
    display: block;
    color: var(--text);
}
.link-desc {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.65rem, 0.59rem + 0.15vw, 0.72rem);
    font-weight: 400;
    color: var(--text-2);
    margin-top: 2px;
    line-height: 1.5;
}
.link-meta {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.62rem, 0.56rem + 0.15vw, 0.68rem);
    font-weight: 400;
    color: var(--text-3);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Chevron ---------- */
.link-chevron {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-3);
    margin-top: 3px;
    transition: transform var(--dur) var(--ease-out), color var(--dur) ease;
}
.link-row:hover .link-chevron {
    transform: translateX(3px);
    color: var(--accent);
}

/* =============================================
   FOOTER
   ============================================= */
.site-footer {
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-3);
    opacity: 0;
    transition: opacity 0.5s ease;
}
.site-footer.visible {
    opacity: 1;
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    align-items: flex-start;
    justify-content: space-between;
}
.footer-copy {
    line-height: 1.6;
}
.footer-copy a {
    color: var(--text-2);
    transition: color var(--dur-fast) ease;
}
.footer-copy a:hover {
    color: var(--accent);
}
.footer-links {
    display: flex;
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.footer-links a {
    color: var(--text-3);
    transition: color var(--dur-fast) ease;
}
.footer-links a:hover {
    color: var(--text);
}

.footer-copy a .brand-accent {
    font-weight: 600;
}

/* =============================================
   CURSOR SPOTLIGHT (link rows)
   ============================================= */
.link-row::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    background: radial-gradient(
        300px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(196, 122, 58, 0.06),
        transparent 60%
    );
    transition: opacity var(--dur) ease;
    pointer-events: none;
}
.link-row:hover::before {
    opacity: 1;
}

/* =============================================
   ENTRANCE ANIMATIONS
   ============================================= */
.hero {
    opacity: 0;
    transform: translateY(16px);
}
.hero.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--spring);
}

.site-header {
    opacity: 0;
}
.site-header.visible {
    opacity: 1;
    transition: opacity 0.4s ease;
}

/* Stagger for link rows inside visible sections */
section.group.visible .link-row {
    opacity: 0;
    transform: translateY(8px);
    animation: row-in 0.45s var(--spring) forwards;
}
section.group.visible .link-row:nth-child(1) { animation-delay: 0.06s; }
section.group.visible .link-row:nth-child(2) { animation-delay: 0.12s; }
section.group.visible .link-row:nth-child(3) { animation-delay: 0.18s; }
section.group.visible .link-row:nth-child(4) { animation-delay: 0.24s; }
section.group.visible .link-row:nth-child(5) { animation-delay: 0.30s; }

@keyframes row-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================
   REDUCED MOTION
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .hero,
    section.group,
    .site-header,
    .site-footer,
    .separator {
        opacity: 1;
        transform: none;
    }
}

/* =============================================
   HIGH CONTRAST
   ============================================= */
@media (prefers-contrast: more) {
    .link-row { border-width: 2px; }
    .theme-toggle { border-width: 2px; }
    .group h2 { border-bottom-width: 2px; }
    .site-footer { border-top-width: 2px; }
}

/* =============================================
   RESPONSIVE — Mobile First Adjustments
   ============================================= */

/* Tablets & small desktops */
@media (max-width: 600px) {
    .wrap {
        padding: 80px 20px 64px;
    }
    .site-header {
        margin-bottom: 56px;
    }
    .hero {
        margin-bottom: 56px;
    }
    section.group {
        margin-bottom: 48px;
    }
    .separator {
        margin-bottom: 48px;
    }
    .link-row {
        padding: 14px 16px;
        gap: 12px;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .wrap {
        padding: 64px 14px 48px;
    }
    .site-header {
        margin-bottom: 40px;
        padding: 0.65rem 0.75rem;
    }
    h1 {
        letter-spacing: -0.02em;
    }
    .hero {
        margin-bottom: 40px;
    }
    section.group {
        margin-bottom: 36px;
    }
    .separator {
        margin-bottom: 36px;
    }
    .link-row {
        padding: 12px 14px;
        gap: 10px;
    }
    .theme-toggle button {
        padding: 0.38rem 0.42rem;
    }
    .footer-inner {
        flex-direction: column;
        gap: 12px;
    }
    .footer-links {
        gap: 12px;
    }
}
