/* The homepage look, used by every page built on includes/site.php (was siteCss()) */

/* Homepage theme (overrides the shared template base styles above) */
/* Developer palette (GitHub-dark style): slate surfaces, link blue accent, terminal green */
:root {
  --h-bg: #0d1117;
  --h-surface: #161b22;
  --h-surface-hover: #1c2129;
  --h-border: rgba(240, 246, 252, 0.1);
  --h-border-hover: rgba(240, 246, 252, 0.22);
  --h-text: #e6edf3;
  --h-muted: #8b949e;
  --h-accent: #58a6ff;
  --h-accent-bg: #1f6feb;
  --h-accent-text: #ffffff;
  --h-term: #3fb950;
  --h-wip: #d29922;
  --h-sun-display: inline-flex;
  --h-moon-display: none;
  --h-fx-opacity: 1;
  --h-scanline: rgba(0, 0, 0, 0.35);
  --h-title-shadow: #238636;
  --h-title-fade: #8b949e;
  --h-glow: rgba(56, 139, 253, 0.12);
  --h-dot: rgba(240, 246, 252, 0.06);
  color-scheme: dark;
}
/* Light theme: from the OS unless the visitor chose dark, or chosen with the toggle */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --h-bg: #e9ecef;
    --h-surface: #f4f5f7;
    --h-surface-hover: #f9fafb;
    --h-border: rgba(31, 35, 40, 0.12);
    --h-border-hover: rgba(31, 35, 40, 0.28);
    --h-text: #1f2328;
    --h-muted: #59636e;
    --h-accent: #0969da;
    --h-accent-bg: #0969da;
    --h-accent-text: #ffffff;
    --h-term: #1a7f37;
    --h-wip: #9a6700;
    --h-sun-display: none;
    --h-moon-display: inline-flex;
    --h-fx-opacity: 0.45;
    --h-scanline: rgba(0, 0, 0, 0.03);
    --h-title-shadow: rgba(26, 127, 55, 0.4);
    --h-title-fade: #57606a;
    --h-glow: rgba(9, 105, 218, 0.08);
    --h-dot: rgba(31, 35, 40, 0.08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --h-bg: #e9ecef;
  --h-surface: #f4f5f7;
  --h-surface-hover: #f9fafb;
  --h-border: rgba(31, 35, 40, 0.12);
  --h-border-hover: rgba(31, 35, 40, 0.28);
  --h-text: #1f2328;
  --h-muted: #59636e;
  --h-accent: #0969da;
  --h-accent-bg: #0969da;
  --h-accent-text: #ffffff;
  --h-term: #1a7f37;
  --h-wip: #9a6700;
  --h-sun-display: none;
  --h-moon-display: inline-flex;
  --h-fx-opacity: 0.45;
  --h-scanline: rgba(0, 0, 0, 0.03);
  --h-title-shadow: rgba(26, 127, 55, 0.4);
  --h-title-fade: #57606a;
  --h-glow: rgba(9, 105, 218, 0.08);
  --h-dot: rgba(31, 35, 40, 0.08);
  color-scheme: light;
}

/* 8bit style: bright arcade palette (cyan, arcade orange, neon green, yellow on deep indigo).
   Placed after the theme blocks so it wins over both; the light variant is a warm cream with
   the same saturated colours, darkened enough to read. */
:root[data-style="retro"] {
  --h-bg: #0b0730;
  --h-surface: #17104a;
  --h-surface-hover: #22196a;
  --h-border: #3f30c8;
  --h-border-hover: #00e5ff;
  --h-text: #ffffff;
  --h-muted: #b3adff;
  --h-accent: #00e5ff;
  --h-accent-bg: #ff7a1a;
  --h-accent-text: #0b0730;
  --h-term: #39ff14;
  --h-wip: #ffd400;
  --h-fx-opacity: 1;
  --h-scanline: rgba(0, 0, 0, 0.3);
  --h-title-shadow: #ff7a1a;
}
@media (prefers-color-scheme: light) {
  :root[data-style="retro"]:not([data-theme="dark"]) {
    --h-bg: #fff3d6;
    --h-surface: #fffaeb;
    --h-surface-hover: #ffefc2;
    --h-border: #6c4cff;
    --h-border-hover: #c24e00;
    --h-text: #1b0f3d;
    --h-muted: #5a3fb5;
    --h-accent: #0055ff;
    --h-accent-bg: #ff7a1a;
    --h-accent-text: #1b0f3d;
    --h-term: #00a316;
    --h-wip: #c25e00;
    --h-fx-opacity: 0.75;
    --h-scanline: rgba(0, 0, 0, 0.04);
    --h-title-shadow: #ffc400;
  }
}
:root[data-style="retro"][data-theme="light"] {
  --h-bg: #fff3d6;
  --h-surface: #fffaeb;
  --h-surface-hover: #ffefc2;
  --h-border: #6c4cff;
  --h-border-hover: #c24e00;
  --h-text: #1b0f3d;
  --h-muted: #5a3fb5;
  --h-accent: #0055ff;
  --h-accent-bg: #ff7a1a;
  --h-accent-text: #1b0f3d;
  --h-term: #00a316;
  --h-wip: #c25e00;
  --h-fx-opacity: 0.75;
  --h-scanline: rgba(0, 0, 0, 0.04);
  --h-title-shadow: #ffc400;
}

html { background: var(--h-bg); }

/* Soft accent glow and dot grid behind the hero, fading out towards the edges */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 55% 45% at 50% 22%, var(--h-glow), transparent 70%),
    radial-gradient(var(--h-dot) 1px, transparent 1.5px);
  background-size: 100% 100%, 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 50% 25%, #000 35%, transparent 80%);
  mask-image: radial-gradient(ellipse 75% 65% at 50% 25%, #000 35%, transparent 80%);
}
html.off body {
  max-width: 760px;
  padding: 0 20px 24px;
  min-height: calc(100vh - 24px);   /* footer at the bottom (css/base.css); 24px padding below */
  min-height: calc(100dvh - 24px);
  color: var(--h-text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.home a, .home a:hover { color: inherit; text-decoration: none; }
.home a:focus-visible, .home button:focus-visible { outline: 2px solid var(--h-accent); outline-offset: 3px; }

/* Icons: line icons for the neutral style, pixel art for the retro style */
.icon-retro { display: none; }
.icon-neutral { display: block; }

/* Toolbar: style and theme switches */
.home { position: relative; }
.toolbar { position: absolute; top: 24px; right: 0; display: flex; gap: 8px; }
/* The style and theme switches need JavaScript; log in/out work without it */
html:not(.js) .style-toggle, html:not(.js) .theme-toggle { display: none; }
.toolbar button, .toolbar .login-link {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0;
  background: var(--h-bg);
  border: 1px solid var(--h-border);
  border-radius: 999px;
  color: var(--h-muted);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.toolbar button:hover, .toolbar .login-link:hover { background: var(--h-surface-hover); border-color: var(--h-border-hover); color: var(--h-text); }
.toolbar .theme-toggle, .toolbar .style-toggle { width: 40px; }
.signout-form { margin: 0; }
.toolbar .signout, .toolbar .login-link { padding: 0 16px; font-size: 0.875rem; font-weight: 500; }
.home .style-toggle[aria-pressed="true"] { border-color: var(--h-accent); color: var(--h-accent); }
.icon-sun { display: var(--h-sun-display); }
.icon-moon { display: var(--h-moon-display); }

/* Hero */
/* The sticky top bar above takes 64px, so the top padding is 32px (the name stays 96px down) */
.hero { margin: 0; padding: 32px 0 56px; text-align: left; }
.group h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
html.bright-theme .hero h1 {
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 3.75rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, var(--h-text) 35%, var(--h-title-fade));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Logged out: the page is just the hero, centered vertically in the window, with the footer
   at the bottom. The body (already full height, css/base.css) becomes a column; the main area
   takes the free space and the hero centers in it. (The background layers are fixed, so they
   are not in the column.) */
body:has(> .home-public) {
  display: flex;
  flex-direction: column;
}
.home-public {
  display: flex;
  flex: 1;
  flex-direction: column;
}
html.off body:has(> .home-public) > footer { margin: 0; }
.home-public .hero {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px 0 88px;   /* + the 64px bar above = centred as with 88px on both sides */
  text-align: center;
}
html.bright-theme .home-public .hero h1 { font-size: clamp(3rem, 11vw, 5rem); }
.hero-lead { margin: 16px 0 0; max-width: 32em; font-size: 1.125rem; color: var(--h-muted); }
.hero-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--h-bg);
  border: 1px solid var(--h-border);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color 0.15s, border-color 0.15s;
}
.home .btn:hover { background: var(--h-surface-hover); border-color: var(--h-border-hover); }
.home .btn-primary, .home .btn-primary:hover {
  background: var(--h-accent-bg);
  border-color: var(--h-accent-bg);
  color: var(--h-accent-text);
}
.home .btn-primary:hover { filter: brightness(1.08); }

/* Link groups */
.group { margin: 0 0 48px; }
.group h2 { margin: 0 0 16px; color: var(--h-muted); }
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0; padding: 0; list-style: none; }
.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-sizing: border-box;
  height: 100%;
  padding: 16px 18px;
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: 12px;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}
.home .card:hover { background: var(--h-surface-hover); border-color: var(--h-border-hover); transform: translateY(-2px); }
.card-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; font-weight: 600; }
.card-sub { font-size: 0.875rem; color: var(--h-muted); }
/* "In progress" badge for unfinished items ("status": "in-progress" in includes/links.json) */
.card-badge {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border: 1px solid var(--h-wip);
  border-radius: 999px;
  color: var(--h-wip);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.arrow { display: inline-flex; flex-shrink: 0; color: var(--h-muted); transition: transform 0.15s, color 0.15s; }
.card-title .arrow { margin-top: 0.3em; }
.btn .arrow { color: inherit; }
.card:hover .arrow { color: var(--h-accent); transform: translateX(2px); }
.card:hover .arrow-external { transform: translate(2px, -2px); }

/* Footer printed by the template */
html.off body > footer {
  margin: 16px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--h-border);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--h-muted);
}
html.off body > footer a { color: var(--h-text); }

/* Retro 8-bit style (html[data-style="retro"], toggled by the Retro button) */
.retro-bg { display: none; }
html[data-style="retro"] .retro-bg {
  display: block;
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--h-fx-opacity);
  /* Quieter behind the content column so text stays readable */
  -webkit-mask-image: linear-gradient(to right, #000 0, rgba(0, 0, 0, 0.35) 28%, rgba(0, 0, 0, 0.35) 72%, #000 100%);
  mask-image: linear-gradient(to right, #000 0, rgba(0, 0, 0, 0.35) 28%, rgba(0, 0, 0, 0.35) 72%, #000 100%);
}
.retro-bg canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.retro-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 2px, var(--h-scanline) 2px, var(--h-scanline) 4px);
}
/* Page weight meter (views/perf-meter.html, filled by views/perf-script.html). Homepage: at
   the left edge of the content column, level with the toolbar at its right edge. Inner pages:
   centred in the top bar (css/top-bar.css). Needs JavaScript */
.perf-meter {
  box-sizing: border-box;
  display: flex;
  width: max-content;
  gap: 10px;
  margin: 0;
  padding: 5px 10px;
  background: var(--h-bg);
  border: 1px solid var(--h-border);
  border-radius: 6px;
  color: var(--h-muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  white-space: nowrap;
}
.perf-weight-value { color: var(--h-term); }
html:not(.js) .perf-meter { display: none; }
html[data-style="retro"] .perf-meter {
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  line-height: 1.6;
  border-radius: 0;
}
@media (max-width: 480px) {
  .perf-meter { padding: 4px 8px; }
}

/* Sticky top bar (homepage .home-bar, inner pages .post-bar in css/top-bar.css): stays at the
   top of the window. Its 12px margin + 12px padding put the buttons 24px from the top, as
   before; the -12px bottom margin keeps what follows where it was. Once the page scrolls
   (html.scrolled, views/bar-script.html) it gets a full-width background and bottom border,
   drawn with box-shadows that clip-path widens to the window edges without adding scroll.
   It switches at once, with no transition: the border is a full-size shadow under the
   background one, so while fading it tinted the whole bar with the border colour (and
   fading the shadows' size flashed the whole window) */
.home-bar, .post-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 12px 0 -12px;
  padding: 12px 0;
  clip-path: inset(0 -100vmax -1px);
}
html.scrolled .home-bar, html.scrolled .post-bar {
  background-color: var(--h-bg);
  box-shadow: 0 0 0 100vmax var(--h-bg), 0 1px 0 100vmax var(--h-border);
}
/* Homepage: the meter at the left edge of the content column, the toolbar at the right */
.home-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.home-bar .toolbar { position: static; margin: 0 0 0 auto; }
html[data-style="retro"] .icon-retro { display: block; }
html[data-style="retro"] .icon-neutral { display: none; }
html.off[data-style="retro"] body {
  font-family: "Pixelify Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: auto;
}
/* Arcade display font for the name and section labels (single weight; no faux bold) */
html.bright-theme[data-style="retro"] .hero h1,
html[data-style="retro"] .group h2 {
  font-family: "Press Start 2P", "Pixelify Sans", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
html[data-style="retro"] .backdrop { display: none; }
html[data-style="retro"] .group h2 { margin-bottom: 20px; }
/* The name as wide as in the normal style: the same fluid size scaled by 0.491, because
   "Fran Marín" is 10em wide in Press Start 2P (monospace) and 4.91em in Inter Bold. The size is
   no longer always a multiple of the font's 8px grid (crisp on high-density screens, pixel
   edges can be slightly uneven on 1x screens) */
html.bright-theme[data-style="retro"] .hero h1 {
  font-size: calc(clamp(2.5rem, 8vw, 3.75rem) * 0.491);
  line-height: 1.25;
  letter-spacing: 0;
  text-shadow: 0.125em 0.125em 0 var(--h-title-shadow);
  background: none;
  color: var(--h-text);
}

@media (min-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; }
}
html.bright-theme[data-style="retro"] .home-public .hero h1 { font-size: calc(clamp(3rem, 11vw, 5rem) * 0.491); }
@media (max-width: 480px) {
  .toolbar { position: static; justify-content: flex-end; }
  .hero { padding: 24px 0 40px; }
  .home-public .hero { padding: 32px 0 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .home *, .home *:hover { transition: none; transform: none !important; }
}
