/* ============================================================================
   Darkeye design system — dark-first cybersecurity identity.
   Two DaisyUI v5 themes (darkeye / darkeye-light) driven by CSS variables,
   self-hosted fonts, base styles, signature components and article typography.
   ============================================================================ */

/* ---- Fonts (self-hosted variable woff2) ---- */
@font-face {
    font-family: "Space Grotesk";
    src: url("/static/fonts/space-grotesk.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "InterVar";
    src: url("/static/fonts/inter.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("/static/fonts/jetbrains-mono.woff2") format("woff2");
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}

/* ---- Theme: darkeye (dark, default) ---- */
[data-theme="darkeye"] {
    color-scheme: dark;
    --color-base-100: #0b0e14;
    --color-base-200: #11151f;
    --color-base-300: #171c29;
    --color-base-content: #e8ecf4;
    --color-primary: #f43f5e;
    --color-primary-content: #fff1f2;
    --color-secondary: #22d3ee;
    --color-secondary-content: #04222b;
    --color-accent: #22d3ee;
    --color-accent-content: #04222b;
    --color-neutral: #1b2130;
    --color-neutral-content: #e8ecf4;
    --color-info: #38bdf8;
    --color-info-content: #04222b;
    --color-success: #34d399;
    --color-success-content: #052e1b;
    --color-warning: #fbbf24;
    --color-warning-content: #2a1c00;
    --color-error: #f87171;
    --color-error-content: #2b0808;
    --radius-selector: 0.25rem;
    --radius-field: 0.5rem;
    --radius-box: 0.75rem;
    --size-selector: 0.25rem;
    --size-field: 0.25rem;
    --border: 1px;
    --depth: 0;
    --noise: 0;

    /* Darkeye custom tokens */
    --tx-secondary: #9aa4b8;
    --tx-muted: #6b7690;
    --bd-default: #232a3b;
    --bd-strong: #38415a;
    --link: #fb7185;
    --grid-line: rgba(148, 163, 184, 0.06);
    --glow-primary: 0 0 0 1px rgba(244, 63, 94, 0.35), 0 8px 30px rgba(244, 63, 94, 0.12);
}

/* ---- Theme: darkeye-light ---- */
[data-theme="darkeye-light"] {
    color-scheme: light;
    --color-base-100: #f7f8fa;
    --color-base-200: #eef1f5;
    --color-base-300: #e2e6ec;
    --color-base-content: #101828;
    --color-primary: #e11d48;
    --color-primary-content: #fff1f2;
    --color-secondary: #0e7490;
    --color-secondary-content: #ecfeff;
    --color-accent: #0e7490;
    --color-accent-content: #ecfeff;
    --color-neutral: #1b2130;
    --color-neutral-content: #f7f8fa;
    --color-info: #0284c7;
    --color-info-content: #ecfeff;
    --color-success: #059669;
    --color-success-content: #ecfdf5;
    --color-warning: #b45309;
    --color-warning-content: #fffbeb;
    --color-error: #dc2626;
    --color-error-content: #fef2f2;
    --radius-selector: 0.25rem;
    --radius-field: 0.5rem;
    --radius-box: 0.75rem;
    --size-selector: 0.25rem;
    --size-field: 0.25rem;
    --border: 1px;
    --depth: 0;
    --noise: 0;

    --tx-secondary: #475467;
    --tx-muted: #667085;
    --bd-default: #d6dce5;
    --bd-strong: #b9c2d0;
    --link: #be123c;
    --grid-line: rgba(16, 24, 40, 0.05);
    --glow-primary: 0 0 0 1px rgba(225, 29, 72, 0.25), 0 8px 30px rgba(225, 29, 72, 0.1);
}

/* ---- Base ---- */
:root {
    --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --font-sans: "InterVar", ui-sans-serif, system-ui, "Noto Sans", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}
body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, .font-display {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}
.font-mono, code, kbd, pre {
    font-family: var(--font-mono);
}
::selection {
    background: color-mix(in srgb, var(--color-primary) 30%, transparent);
}
:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
    border-radius: 2px;
}
::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}
::-webkit-scrollbar-track {
    background: var(--color-base-200);
}
::-webkit-scrollbar-thumb {
    background: var(--bd-strong);
    border-radius: 6px;
    border: 3px solid var(--color-base-200);
}

/* Utility text colors that flip with the theme */
.text-ink-2 { color: var(--tx-secondary); }
.text-ink-3 { color: var(--tx-muted); }
.border-line { border-color: var(--bd-default); }
.border-line-strong { border-color: var(--bd-strong); }
.bg-surface { background: var(--color-base-200); }

/* Skip link */
.skip-link {
    position: fixed;
    top: -3rem;
    left: 1rem;
    z-index: 100;
    background: var(--color-primary);
    color: var(--color-primary-content);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-field);
    transition: top 0.2s var(--ease-out);
}
.skip-link:focus {
    top: 1rem;
}

/* Signature grid texture (hero / footer / error) */
.bg-grid {
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
}

/* ---- Signature components ---- */

/* Brand mark — never squashed by flex, always keeps its aspect ratio */
.brand-mark {
    flex: none;
    height: 2.5rem;
    width: auto;
    max-width: none;
    aspect-ratio: 128 / 91;
    object-fit: contain;
}
.brand-mark-lg {
    height: 3rem;
}
@media (max-width: 640px) {
    .brand-mark {
        height: 2.1rem;
    }
}

/* Monospace micro-label — the brand's signature accent */
.mono-label {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-secondary);
}

/* Category / tag chip */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--bd-default);
    border-radius: 999px;
    color: var(--tx-secondary);
    transition: border-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
a.chip:hover {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

/* Card with hairline border + subtle lift */
.card-darkeye {
    background: var(--color-base-200);
    border: 1px solid var(--bd-default);
    border-radius: var(--radius-box);
    overflow: hidden;
    transition: transform 0.18s var(--ease-out), border-color 0.18s var(--ease-out),
        box-shadow 0.18s var(--ease-out);
}
.card-darkeye:hover {
    transform: translateY(-3px);
    border-color: var(--bd-strong);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
[data-theme="darkeye-light"] .card-darkeye:hover {
    box-shadow: 0 10px 40px rgba(16, 24, 40, 0.1);
}

/* Primary button glow on hover */
.btn-primary {
    transition: box-shadow 0.2s var(--ease-out), filter 0.2s var(--ease-out);
}
.btn-primary:hover {
    box-shadow: var(--glow-primary);
}

/* Segmented control (sort tabs) */
.segmented {
    display: inline-flex;
    padding: 0.2rem;
    gap: 0.15rem;
    background: var(--color-base-200);
    border: 1px solid var(--bd-default);
    border-radius: var(--radius-field);
}
.segmented a {
    font-size: 0.85rem;
    padding: 0.35rem 0.8rem;
    border-radius: calc(var(--radius-field) - 0.15rem);
    color: var(--tx-secondary);
    transition: all 0.15s var(--ease-out);
}
.segmented a.active,
.segmented a[aria-current="true"] {
    background: var(--color-primary);
    color: var(--color-primary-content);
}
.segmented a:not(.active):hover {
    color: var(--color-base-content);
    background: var(--color-base-300);
}

/* Reading progress bar (post pages) */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    z-index: 60;
    transition: width 0.1s linear;
}

/* Table of contents */
.toc a {
    display: block;
    padding: 0.25rem 0 0.25rem 0.85rem;
    border-left: 2px solid var(--bd-default);
    color: var(--tx-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.toc a.toc-h3 { padding-left: 1.6rem; font-size: 0.85rem; }
.toc a:hover { color: var(--color-base-content); }
.toc a.active {
    color: var(--color-secondary);
    border-left-color: var(--color-secondary);
}

/* Scroll-reveal (JS adds .revealed) */
.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}
.reveal.revealed {
    opacity: 1;
    transform: none;
}

/* Back-to-top button */
.back-to-top {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease-out);
}
.back-to-top.show {
    opacity: 1;
    pointer-events: auto;
}

/* ---- Article typography (.prose-darkeye) — replaces markdown.css ---- */
.prose-darkeye {
    font-size: 1.075rem;
    line-height: 1.78;
    color: var(--color-base-content);
    max-width: 72ch;
}
.prose-darkeye > * + * { margin-top: 1.25rem; }
.prose-darkeye h2,
.prose-darkeye h3,
.prose-darkeye h4 {
    font-family: var(--font-display);
    line-height: 1.25;
    scroll-margin-top: 5.5rem;
    margin-top: 2.4rem;
}
.prose-darkeye h2 { font-size: 1.7rem; }
.prose-darkeye h3 { font-size: 1.35rem; }
.prose-darkeye h2::before {
    content: "# ";
    color: var(--color-secondary);
    font-family: var(--font-mono);
    opacity: 0.6;
}
.prose-darkeye a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}
.prose-darkeye a:hover { text-decoration-thickness: 2px; }
.prose-darkeye strong { color: var(--color-base-content); font-weight: 700; }
.prose-darkeye ul,
.prose-darkeye ol { padding-left: 1.4rem; }
.prose-darkeye ul { list-style: none; }
.prose-darkeye ul > li { position: relative; }
.prose-darkeye ul > li::before {
    content: "▹";
    position: absolute;
    left: -1.2rem;
    color: var(--color-secondary);
}
.prose-darkeye ol { list-style: decimal; }
.prose-darkeye li + li { margin-top: 0.4rem; }
.prose-darkeye blockquote {
    border-left: 2px solid var(--color-primary);
    padding: 0.3rem 0 0.3rem 1.1rem;
    color: var(--tx-secondary);
    background: var(--color-base-200);
    border-radius: 0 var(--radius-field) var(--radius-field) 0;
}
.prose-darkeye img {
    border-radius: var(--radius-box);
    border: 1px solid var(--bd-default);
    cursor: zoom-in;
    max-width: 100%;
    height: auto;
}
.prose-darkeye hr { border-color: var(--bd-default); margin: 2.5rem 0; }
.prose-darkeye code {
    font-size: 0.9em;
    background: var(--color-base-300);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}
.prose-darkeye pre {
    position: relative;
    background: #0d1117;
    border: 1px solid var(--bd-default);
    border-radius: var(--radius-box);
    padding: 1rem 1.1rem;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.6;
}
.prose-darkeye pre code {
    background: transparent;
    padding: 0;
    color: #c9d1d9;
}
.prose-darkeye table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.prose-darkeye th,
.prose-darkeye td {
    border: 1px solid var(--bd-default);
    padding: 0.55rem 0.8rem;
    text-align: left;
}
.prose-darkeye th {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-base-200);
}
.prose-darkeye .spoiler {
    filter: blur(5px);
    transition: filter 0.2s var(--ease-out);
    cursor: pointer;
}
.prose-darkeye .spoiler:hover,
.prose-darkeye .spoiler:focus-within { filter: none; }
.prose-darkeye iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-box);
    border: 1px solid var(--bd-default);
}

/* Copy-to-clipboard button on code blocks */
.code-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--bd-strong);
    border-radius: 4px;
    background: var(--color-base-200);
    color: var(--tx-secondary);
    opacity: 0;
    transition: opacity 0.15s var(--ease-out);
    cursor: pointer;
}
.prose-darkeye pre:hover .code-copy { opacity: 1; }

/* Pygments token colors (if server-side highlighting is enabled) */
.codehilite .k, .codehilite .kd, .codehilite .kn { color: #ff7b9c; }
.codehilite .s, .codehilite .s1, .codehilite .s2 { color: #7ee787; }
.codehilite .c, .codehilite .c1, .codehilite .cm { color: #6b7690; font-style: italic; }
.codehilite .n, .codehilite .nv { color: #c9d1d9; }
.codehilite .nf, .codehilite .nc { color: #22d3ee; }
.codehilite .mi, .codehilite .mf { color: #f0b429; }
.codehilite .o, .codehilite .p { color: #9aa4b8; }

/* ---- View transitions + motion ---- */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
    .card-darkeye:hover { transform: none; }
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) { animation: none !important; }
    .reading-progress { display: none; }
}
