/* Global base styles. Colors/spacing come from css/tokens.css. */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.65;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-4); letter-spacing: -0.02em; }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-4); }

a { color: var(--color-accent); text-underline-offset: 3px; }
a:hover { color: var(--color-link-hover); }
:focus-visible { outline: 2px solid var(--color-highlight); outline-offset: 3px; border-radius: var(--radius-sm); }
/* Blazor's <FocusOnNavigate> focuses the page's h1 after navigation (for screen readers);
   that focus is programmatic, so don't draw an outline around the heading. */
h1:focus, h1:focus-visible { outline: none; }

code, pre { font-family: var(--font-mono); font-size: 0.9em; }
pre {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    overflow-x: auto;
}
:not(pre) > code {
    background: var(--color-surface-2);
    padding: 0.1em 0.35em;
    border-radius: var(--radius-sm);
}

/* Layout helpers */
.container { width: min(100% - 2 * var(--space-6), var(--container)); margin-inline: auto; }
.section { margin-block: var(--space-16); }
.section-header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); margin-bottom: var(--space-8); }
.section-header > :last-child:not(:first-child) { white-space: nowrap; }
.section-header h2 { margin: 0; }
.grid { display: grid; gap: var(--space-6); grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.stack > * + * { margin-top: var(--space-6); }
.muted { color: var(--color-text-muted); }
/* The one small uppercase label style: field names, group names, card captions. */
.label, .eyebrow {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
/* The same label above a heading, in the accent colour (the cyan highlight is below 4.5:1 on the light background). */
.eyebrow { color: var(--color-accent); margin-bottom: var(--space-3); }
/* Heading scale: page title (h1) > section title (h2 that opens a page section) > h2 inside text > h3 in cards. */
.page-title { font-size: var(--text-3xl); margin-bottom: var(--space-3); }
.section-title { font-size: var(--text-2xl); }
.page-intro { margin-bottom: var(--space-12); }
.page-intro .section-title { margin-bottom: var(--space-3); }
.lead { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 42rem; }

/* Components */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
}
/* Only cards that are links react to the pointer; static cards stay still, so nothing looks clickable that isn't. */
.card-interactive { transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s; }
/* Keyboard focus (on the card or a link inside it) gets the same lift as the pointer. :is() takes a forgiving
   selector list, so a browser without :has() ignores only that part. */
.card-interactive:is(:hover, :focus-visible, :has(:focus-visible)) {
    border-color: color-mix(in srgb, var(--color-accent) 55%, var(--color-border));
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    background: var(--color-accent-strong);
    color: var(--color-accent-contrast);
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.2s;
}
.btn:hover { background: var(--color-accent); color: var(--color-accent-contrast); }
.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.btn-ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }

.tags { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; margin: 0; }
.tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-full);
    background: color-mix(in srgb, var(--color-accent) 14%, transparent);
    /* Accent pulled towards the text colour: the plain accent on its own tint is 4.1:1 on dark cards. */
    color: color-mix(in srgb, var(--color-accent) 80%, var(--color-text));
    border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent);
}
/* "+3" chip when a card shows only the first few technologies. */
.tag-more {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

/* Seasonal effects canvas: fixed behind content, never intercepts clicks. */
.season-fx {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Theme toggle: show the icon of the theme you'd switch TO. */
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Seasonal toggle: show the icon of today's season/holiday (autumn leaf as fallback). */
.season-icon { display: none; }
:root:not([data-season-now]) .icon-autumn,
[data-season-now="spring"] .icon-spring,
[data-season-now="summer"] .icon-summer,
[data-season-now="autumn"] .icon-autumn,
[data-season-now="winter"] .icon-winter,
[data-season-now="christmas"] .icon-christmas,
[data-season-now="newyear"] .icon-newyear { display: block; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: var(--space-4); top: var(--space-4); z-index: 100; background: var(--color-surface); padding: var(--space-2) var(--space-4); }

/* Rendered Markdown */
.prose { max-width: 46rem; }
.prose li + li { margin-top: var(--space-2); }
.prose h2 { margin-top: var(--space-10); }
.prose img { max-width: 100%; border-radius: var(--radius-md); }
.prose blockquote { margin: 0; padding-left: var(--space-4); border-left: 3px solid var(--color-accent); color: var(--color-text-muted); }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .card-interactive { transition: none; }
}

/* Image viewer: the <dialog> is created by js/lightbox.js, so its styles are global. */
html.lightbox-open { overflow: hidden; }

.lightbox {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-overlay-text);
}
.lightbox::backdrop { background: var(--color-overlay); }
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; }

.lightbox-stage {
    display: grid;
    place-items: center;
    min-height: 0;
    padding: var(--space-16) var(--space-16) var(--space-2);
}
.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}
.lightbox-bar {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-6) var(--space-6);
    text-align: center;
}
.lightbox-bar p { margin: 0; }
.lightbox-caption { max-width: 46rem; }
.lightbox-count { font-family: var(--font-mono); font-size: var(--text-sm); opacity: 0.75; white-space: nowrap; }

.lightbox-btn {
    position: absolute;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    font: inherit;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--color-overlay-text);
    background: var(--color-overlay-control);
    cursor: pointer;
}
.lightbox-btn:hover, .lightbox-btn:focus-visible { background: var(--color-overlay-control-hover); }
.lightbox-btn:focus-visible { outline: 2px solid var(--color-overlay-text); outline-offset: 2px; }
.lightbox-close { top: var(--space-4); right: var(--space-4); font-size: 1.25rem; }
.lightbox-prev, .lightbox-next { top: 50%; transform: translateY(-50%); }
.lightbox-prev { left: var(--space-4); }
.lightbox-next { right: var(--space-4); }
.lightbox[data-single] .lightbox-prev, .lightbox[data-single] .lightbox-next { display: none; }

@media (max-width: 720px) {
    .lightbox-stage { padding: var(--space-16) var(--space-2) var(--space-2); }
    .lightbox-prev, .lightbox-next { top: auto; bottom: var(--space-4); transform: none; }
    .lightbox-bar { padding-inline: 4.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
    .lightbox[open] { animation: lightbox-in 0.15s ease-out; }
    @keyframes lightbox-in { from { opacity: 0; } }
}

/* Not found / error pages: centred in the viewport rather than a short block at the top. */
.error-page { min-height: 55vh; display: flex; flex-direction: column; justify-content: center; }
.error-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-8); }
