/* ==========================================================================
   Ambient Screens — shared base styles
   Design tokens, header, footer, buttons, controls, content and AD SLOTS.
   ========================================================================== */

:root {
  /* Colour tokens (dark by default) */
  --bg: #0b0b10;
  --bg-2: #14141c;
  --surface: #1b1b26;
  --surface-2: #252534;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f1f1f6;
  --text-dim: #a4a4b8;
  --accent: #ff7a3d;
  --accent-2: #ffb347;
  --focus: #7cc4ff;

  /* Type + spacing */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 48px; /* minimum tap target */
  --wrap: 1080px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.6 var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, svg, canvas { max-width: 100%; display: block; }
a { color: var(--accent-2); }
a:hover { color: #fff; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }

/* Visible focus for keyboard users */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: #111; padding: 10px 16px; border-radius: 8px;
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Header / footer ---------- */
.site-header { border-bottom: 1px solid var(--border); background: rgba(11, 11, 16, 0.85); backdrop-filter: blur(10px); position: relative; z-index: 5; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.brand-dot { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent) 60%, #b3261e); box-shadow: 0 0 16px rgba(255, 122, 61, 0.6); }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--text-dim); text-decoration: none; padding: 10px 14px; border-radius: 999px; min-height: 44px; display: inline-flex; align-items: center; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); background: var(--surface); }

.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 32px 0 48px; color: var(--text-dim); font-size: 14px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; }
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--text); }

/* ---------- Buttons & form controls ---------- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; min-height: var(--tap); padding: 0 20px; border-radius: 999px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: background 0.2s, transform 0.1s, border-color 0.2s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn[aria-pressed="true"], .btn.is-active { background: var(--accent); color: #1a0d05; border-color: transparent; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon { width: var(--tap); padding: 0; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
select, input[type="range"] { font: inherit; }
select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  min-height: var(--tap); border-radius: var(--radius-sm); padding: 0 12px;
}
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--accent-2); border: 0; box-shadow: 0 0 0 4px rgba(255, 179, 71, 0.2); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-2); border: 0; }

/* ---------- Tool cards (home) ---------- */
.hero { padding: 72px 0 32px; text-align: center; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); margin: 0 0 12px; }
.hero p { color: var(--text-dim); font-size: 1.15rem; max-width: 36em; margin: 0 auto; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 32px 0; }
.card {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: transform 0.2s, border-color 0.2s;
}
a.card:hover { transform: translateY(-4px); border-color: rgba(255, 255, 255, 0.25); color: var(--text); }
.card-art { aspect-ratio: 16 / 9; position: relative; overflow: hidden; }
.card-body { padding: 18px 20px 22px; }
.card-body h2 { margin: 0 0 6px; font-size: 1.3rem; }
.card-body p { margin: 0; color: var(--text-dim); font-size: 0.95rem; }
.card.soon .card-art { opacity: 0.45; }
.card.soon { border-style: dashed; }
.card.soon .card-body p { color: #b8b8cb; }
.card.soon .badge { color: #c9c9da; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); margin-bottom: 8px; }
.card-art.lava { background: #7a0f10; }
.card-art.lava i { position: absolute; border-radius: 50%; background: radial-gradient(circle, #ffc14d, #ff5a1f 70%); filter: blur(14px); animation: float 9s ease-in-out infinite alternate; }
.card-art.lava i:nth-child(1) { width: 40%; aspect-ratio: 1; left: 12%; top: 40%; }
.card-art.lava i:nth-child(2) { width: 28%; aspect-ratio: 1; left: 52%; top: 10%; animation-delay: -3s; }
.card-art.lava i:nth-child(3) { width: 34%; aspect-ratio: 1; left: 62%; top: 52%; animation-delay: -6s; }
.card-art.noise { background: linear-gradient(135deg, #1a1030, #2a1650 60%, #0e0a1c); }
.card-art.noise svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.card-art.placeholder { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 12px, var(--surface) 12px, var(--surface) 24px); }
@keyframes float { from { transform: translate(0, 0) scale(1); } to { transform: translate(8%, -22%) scale(1.15); } }

/* ---------- Long-form content ---------- */
.prose { max-width: 720px; margin: 0 auto; }
.prose h2 { margin-top: 2.2em; font-size: 1.6rem; }
.prose h3 { margin-top: 1.6em; font-size: 1.2rem; }
.prose p, .prose li { color: #d3d3e0; }
.prose details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 10px 0; padding: 0 18px; }
.prose summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }
.prose details p { margin-top: 0; }

/* ---------- Reduced-motion notice ---------- */
.motion-notice {
  display: none; margin: 12px auto; max-width: 720px; padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-dim); font-size: 14px; text-align: center;
}
@media (prefers-reduced-motion: reduce) { .motion-notice { display: block; } .card-art.lava i { animation: none; } }

/* ==========================================================================
   AD SLOTS  (prepared, NOT active)
   Rules: ads live ONLY in the scroll area below the tool. Never inside the
   full-screen / ambient view. Each slot reserves a fixed height so the
   layout never shifts (CLS). Slots are hidden until body.ads-on is set by
   shared.js (flag ADS_ENABLED).
   ========================================================================== */
.ad-slot { display: none; margin: 32px auto; width: 100%; max-width: 970px; text-align: center; }
body.ads-on .ad-slot { display: block; }
.ad-slot::before { content: "Advertisement"; display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }
.ad-slot .ad-box { background: var(--bg-2); border: 1px dashed var(--border); border-radius: 8px; overflow: hidden; }
.ad-below-tool .ad-box { height: 280px; }   /* below the tool */
.ad-in-content .ad-box { height: 280px; }   /* inside the article */
.ad-sidebar { display: none !important; }   /* optional desktop sidebar */
@media (min-width: 1360px) {
  body.ads-on .ad-sidebar { display: block !important; position: absolute; right: 24px; width: 160px; margin: 0; }
  .ad-sidebar .ad-box { height: 600px; }
}
@media (max-width: 600px) { .ad-below-tool .ad-box, .ad-in-content .ad-box { height: 260px; } }

/* ---------- Cookie consent (only shown when ads are enabled) ---------- */
.consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50; max-width: 560px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); font-size: 14px;
}
.consent p { margin: 0 0 12px; color: var(--text-dim); }
.consent .row { display: flex; gap: 10px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Full-screen stage (shared by Lava Lamp-style tools: fireplace, rain, dead
   pixel test). The stage is the ONLY thing that goes fullscreen; ads and
   article content live below it and are never part of it.
   ========================================================================== */
.stage { position: relative; height: 100vh; height: 100svh; background: #000; overflow: hidden; }
.stage:fullscreen { height: 100%; }
.stage canvas.fill { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage-top { position: absolute; top: 0; left: 0; right: 0; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; transition: opacity .6s; z-index: 2; }
.stage-top a { text-shadow: 0 1px 8px rgba(0,0,0,.6); color: #fff; opacity: .85; text-decoration: none; font-weight: 600; }
.controls {
  position: absolute; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: end; justify-content: center;
  width: max-content; max-width: calc(100% - 24px); padding: 14px 18px;
  background: rgba(12,12,18,.62); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 22px; transition: opacity .6s; z-index: 3;
}
.controls label.field { min-width: 120px; }
.controls [hidden] { display: none !important; }
.hint { position: absolute; top: 64px; left: 0; right: 0; text-align: center; font-size: 13px; color: rgba(255,255,255,.55); transition: opacity .6s; pointer-events: none; z-index: 2; }
body.is-idle .controls, body.is-idle .stage-top, body.is-idle .hint { opacity: 0; pointer-events: none; }
body.is-idle .stage { cursor: none; }
.scroll-cue { text-align: center; padding: 28px 0 0; color: var(--text-dim); font-size: 14px; }
@media (max-width: 600px) { .controls { gap: 10px; padding: 12px; border-radius: 18px; } .controls label.field { min-width: 100px; } .hint { display: none; } }
kbd { background: var(--surface-2); border-radius: 5px; padding: 1px 6px; font-size: .9em; }

/* Home card artwork for the extra tools */
.card-art.fire { background: radial-gradient(ellipse at 50% 100%, #ffb347 0, #ff5a1f 28%, #5a0f06 62%, #120505 100%); }
.card-art.rain { background: linear-gradient(160deg, #1b2a45, #0b1020); }
.card-art.rain i { position: absolute; width: 6%; aspect-ratio: .6; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: rgba(190,215,255,.45); box-shadow: inset -2px -2px 3px rgba(255,255,255,.35); }
.card-art.pixel { background: linear-gradient(90deg, #f00 0 20%, #0f0 20% 40%, #00f 40% 60%, #fff 60% 80%, #000 80%); }
.card-art.tone { background: #120f22; }
.card-art.tone svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- "More calm tools" links at the bottom of each tool page (internal linking) ---------- */
.more-tools { max-width: var(--wrap); margin: 56px auto 0; padding: 0 20px; }
.more-tools h2 { font-size: 1.2rem; margin: 0 0 14px; }
.more-tools ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.more-tools a { display: flex; flex-direction: column; gap: 4px; min-height: var(--tap); padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.more-tools a:hover { background: var(--surface-2); }
.more-tools span { color: var(--text-dim); font-size: 13px; line-height: 1.4; }

/* ---------- Small-screen fixes ---------- */
/* Long unbreakable text (share links, code) must wrap instead of widening the page. Flex children also need min-width: 0. */
body > main, .prose, .wrap { min-width: 0; }
.prose { overflow-wrap: break-word; }
.prose code { overflow-wrap: anywhere; word-break: break-word; background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
/* Comfortable tap targets for the brand link and the links on top of full-screen tools */
.brand { min-height: 44px; }
.stage-top a { display: inline-flex; align-items: center; min-height: 44px; }
/* Finger-friendly sliders on touch screens */
@media (pointer: coarse) {
  input[type="range"] { height: 44px; }
  input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -11px; }
  input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; }
}


/* ---------- Home / hub: compact tool tiles grouped by category ---------- */
.home-cats { margin-top: 48px; display: grid; gap: 40px; }
.cat-h { font-size: 1.5rem; margin: 0 0 4px; }
.cat-d { margin: 0 0 16px; color: var(--text-dim); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; min-height: var(--tap); padding: 16px 18px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .28); color: var(--text); }
.tile strong { font-size: 1.05rem; }
.tile span { color: var(--text-dim); font-size: 14px; line-height: 1.45; }
