/* styles.css
 * Glowing blob background with time-varying gradient stops.
 * Foreground content is centred in a fixed-width column and scrolls vertically.
 */

:root {
  /* Updated continuously by main.js */
  --blob-stop-1: rgb(127, 255, 212);
  --blob-stop-2: rgb(147, 112, 219);

  /* Slightly warm site palette (chosen to complement the cool blob gradient) */
  --bg: #0d0b0a;                              /* warm near-black */
  --bg-rgb: 13, 11, 10;                       /* same colour as --bg, as RGB triplet */
  --fg: #f5f1e8;                              /* warm off-white */
  --muted: #c8c1b6;                           /* warm muted text */
  --border: rgba(245, 241, 232, 0.12);        /* subtle warm border */
  --surface: rgba(245, 241, 232, 0.04);       /* subtle warm surface */
  --link: #f3b36b;                            /* warm accent for links (no visited shift) */

  /* Foreground column sizing (ChatGPT-style centred column) */
  --content-max: 900px;
  --content-pad-x: 1.25rem;
  --content-pad-y: 1.5rem;

  /* Spacing between stacked cards */
  --card-gap: 1.25rem;

  /* How much to dim the blob behind each card (0..1) */
  --card-dim-alpha: 0.78;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;

  /* Page background */
  background-color: var(--bg);

  /* Allow the page content to scroll vertically */
  overflow-y: auto;
  overflow-x: hidden;

  /* Base typography */
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue",
               Arial, sans-serif;
  line-height: 1.55;

  /* Hint to the browser that this is a dark UI (form controls, etc.) */
  color-scheme: dark;
}

/* Text selection */
::selection {
  background: rgba(243, 179, 107, 0.35);
}

/* Links: keep a consistent colour across states (including :visited). */
a,
a:visited {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover,
a:focus-visible {
  text-decoration-thickness: 2px;
}

a:active {
  color: var(--link);
}

/* Blob: animated gradient shape following the pointer.
 * Use fixed positioning so it stays anchored to the viewport while the page scrolls.
 */
#blob {
  position: fixed;
  top: 50%;
  left: 50%;
  translate: -50% -50%;

  width: 15vmax;
  aspect-ratio: 1;
  border-radius: 50%;

  background: linear-gradient(to right, var(--blob-stop-1), var(--blob-stop-2));
  animation: rotate 20s infinite;
  opacity: 0.85;

  /* Behind everything */
  z-index: 0;
}

/* Rotation and mild distortion for organic movement */
@keyframes rotate {
  from { rotate: 0deg; }
  50%  { scale: 1 1.4; }
  to   { rotate: 360deg; }
}

/* Blur overlay that diffuses the blob’s light (always viewport-fixed) */
#blur {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(12vmax);
  pointer-events: none;
  z-index: 1;
}

/* Foreground layout: centred, readable column (not centred text). */
header, main, footer {
  position: relative;
  z-index: 2;

  width: min(100% - (2 * var(--content-pad-x)), var(--content-max));
  margin-left: auto;
  margin-right: auto;

  /* Keep content off the edges on small screens */
  padding-left: var(--content-pad-x);
  padding-right: var(--content-pad-x);
}

/* Spacing similar to a chat UI content column */
header {
  padding-top: var(--content-pad-y);
  padding-bottom: 0.75rem;
}

main {
  padding-top: 0.75rem;
  padding-bottom: 3rem; /* room at bottom so the last line isn’t flush to edge */
}

footer {
  padding-top: 0.75rem;
  padding-bottom: var(--content-pad-y);
  opacity: 0.9;
  color: var(--muted);
}

/* Optional: if you still use a .container wrapper in older pages, keep it centred too */
.container {
  width: min(100% - (2 * var(--content-pad-x)), var(--content-max));
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--content-pad-x);
  padding-right: var(--content-pad-x);
}

/* Common “card” blocks (if used by your templates)
 * Card-only dimming: the overlay sits on the card and darkens what is behind it.
 */
.card {
  position: relative; /* required for ::before overlay positioning */
  border: 1px solid var(--border);
  border-radius: 12px;

  /* Internal padding */
  padding: 1rem 1.25rem;

  /* External spacing between cards */
  margin: 0 0 var(--card-gap) 0;

  /* The dimming overlay provides the background, so keep this transparent */
  background: transparent;
}

/* Card-only dimmer + surface tint (affects only the area behind the card) */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;

  /* Two layers:
     1) subtle surface tint (to keep the card readable)
     2) stronger background-colour overlay to dim anything behind the card */
  background:
    linear-gradient(var(--surface), var(--surface)),
    linear-gradient(rgba(var(--bg-rgb), var(--card-dim-alpha)),
                    rgba(var(--bg-rgb), var(--card-dim-alpha)));

  z-index: 0;
}

/* Ensure card content renders above the overlay */
.card > * {
  position: relative;
  z-index: 1;
}

.card:last-child {
  margin-bottom: 0;
}

/* Muted metadata text (dates, reading time, etc.) */
.meta {
  color: var(--muted);
}

/* Ensure long code/URLs do not force horizontal scrolling of the whole page */
pre, code {
  overflow-x: auto;
  max-width: 100%;
}

pre {
  background: rgba(245, 241, 232, 0.035);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

code {
  background: rgba(245, 241, 232, 0.04);
  border-radius: 6px;
  padding: 0.1rem 0.25rem;
}
