/* Colors for every page, in dark (default) and light mode.
   Pages only use these variables, so switching data-theme on <html> restyles everything. */
:root {
  color-scheme: dark;
  --bg: #0d0d0f;
  --text: #fcfbf8;
  --muted: rgba(252, 251, 248, 0.6);
  --faint: rgba(252, 251, 248, 0.4);
  --box: #1c1c1e;
  --field: #141416;
  --field-hover: #1f1f22;
  --box-border: rgba(255, 255, 255, 0.08);
  --field-border: rgba(255, 255, 255, 0.12);
  --strong-border: rgba(255, 255, 255, 0.3);
  --chip: rgba(255, 255, 255, 0.06);
  --glass: rgba(24, 24, 27, 0.7);
  --glass-hover: rgba(40, 40, 44, 0.8);
  --on-text: #111111;          /* text on the white "primary" buttons */
  --shadow: rgba(0, 0, 0, 0.45);
  --code-fade: rgba(255, 255, 255, 0.25);
  --toast-bg: #ffffff;
  --toast-text: #111111;
  --error: #ff6b6b;
  --ok: #4ade80;
  --ok-inverse: #15803d;       /* green on a primary-colored surface */
  --glow-opacity: 0.85;
  --focus-ring: rgba(255, 255, 255, 0.16);  /* soft ring around focused fields and selected options */
  --grid-line: rgba(255, 255, 255, 0.05);  /* faint background grid */
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f5f1;
  --text: #16161a;
  --muted: rgba(22, 22, 26, 0.62);
  --faint: rgba(22, 22, 26, 0.42);
  --box: #ffffff;
  --field: #f4f3ef;
  --field-hover: #ecebe6;
  --box-border: rgba(22, 22, 26, 0.08);
  --field-border: rgba(22, 22, 26, 0.14);
  --strong-border: rgba(22, 22, 26, 0.32);
  --chip: rgba(22, 22, 26, 0.05);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-hover: rgba(255, 255, 255, 0.92);
  --on-text: #ffffff;
  --shadow: rgba(40, 30, 80, 0.10);
  --code-fade: rgba(22, 22, 26, 0.22);
  --toast-bg: #16161a;
  --toast-text: #ffffff;
  --error: #d93636;
  --ok: #16a34a;
  --ok-inverse: #4ade80;
  --glow-opacity: 0;          /* plain light background, no glow */
  --grid-line: rgba(22, 22, 26, 0.06);
  --focus-ring: rgba(22, 22, 26, 0.12);
}

body { transition: background-color .25s, color .25s; }

/* Light / dark switch in the header */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; padding: 0; border-radius: 999px;
  background: transparent; border: 1px solid var(--box-border);
  color: var(--muted); cursor: pointer;
  transition: color .15s, background .15s;
}
.theme-toggle:hover { color: var(--text); background: var(--chip); }
.theme-toggle:focus-visible { outline: 2px solid var(--strong-border); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: block; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }

/* "Logo" placeholder: always leads back to the homepage */
.home-link {
  font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
  color: var(--text); text-decoration: none; flex: none;
}
.home-link:hover { opacity: 0.75; }
.home-link:focus-visible { outline: 2px solid var(--strong-border); outline-offset: 4px; border-radius: 4px; }
footer .home-link { font-size: 15px; }
header { gap: 12px; }
header .header-link { margin-left: auto; }
header nav { margin-left: 20px; }

/* Faint checkered grid behind every page, fading out towards the edges.
   The element is added by theme.js; it stays put while the page scrolls. */
.grid-bg {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: center top;
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 50% 40%, #000 35%, transparent 100%);
  mask-image: radial-gradient(ellipse 75% 65% at 50% 40%, #000 35%, transparent 100%);
}

/* Phones: iOS Safari zooms in on any field with text smaller than 16px.
   Keep form text at 16px on small screens so tapping a field never zooms. */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}

/* Logo mark: drawn in the text colour, so it is dark in light mode and light in dark mode */
.home-link { display: inline-flex; align-items: center; }
.home-link .logo-mark { display: block; width: 28px; height: 28px; border-radius: 0; }
footer .home-link .logo-mark { width: 22px; height: 22px; }

/* Logo + name ("Joltura" wordmark next to the mark) */
.home-link { gap: 10px; }
.home-link .logo-mark { width: 26px; height: 26px; }
.logo-name { font-size: 21px; font-weight: 700; letter-spacing: -0.045em; line-height: 1; }
footer .home-link { gap: 8px; }
footer .home-link .logo-mark { width: 20px; height: 20px; }
footer .logo-name { font-size: 16px; }

/* Header like the homepage: logo left, menu in the middle, buttons right */
header:has(> nav) { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; z-index: 10; }
header:has(> nav) > .home-link { justify-self: start; }
header:has(> nav) > nav { justify-self: center; margin-left: 0; font-weight: 500; }
header:has(> nav) > .actions { justify-self: end; margin-left: 0; }

/* Phone menu button and panel (built by theme.js) */
.menu-toggle {
  display: none; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; padding: 0; border-radius: 999px;
  background: transparent; border: 1px solid var(--box-border);
  color: var(--text); cursor: pointer;
}
.menu-toggle:hover { background: var(--chip); }
.menu-toggle:focus-visible { outline: 2px solid var(--strong-border); outline-offset: 2px; }
.menu-toggle svg { width: 18px; height: 18px; display: block; }
.menu-toggle .close, .menu-toggle.is-open .open { display: none; }
.menu-toggle.is-open .close { display: block; }
.mobile-menu {
  /* phones: the menu covers the whole screen under the header */
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; gap: 4px;
  padding: 88px 24px calc(28px + env(safe-area-inset-bottom));
  background: var(--bg); overflow-y: auto;
  animation: menu-in .22s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .mobile-menu { animation: none; } }
.mobile-menu[hidden] { display: none; }
/* logo and buttons stay visible on top of the open menu */
header:has(> .mobile-menu:not([hidden])) > .home-link,
header:has(> .mobile-menu:not([hidden])) > .actions { position: relative; z-index: 21; }
html.menu-open { overflow: hidden; }
header:has(> .mobile-menu:not([hidden])) .actions .btn-light { visibility: hidden; }
/* big text links: only the words react on hover, no full-width highlight */
.mobile-menu a {
  align-self: flex-start; padding: 10px 0;
  font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2;
  color: var(--text); text-decoration: none;
  text-decoration-line: underline; text-decoration-color: transparent;
  text-decoration-thickness: 2px; text-underline-offset: 6px;
  transition: color .15s, text-decoration-color .15s;
}
.mobile-menu a:hover, .mobile-menu a:focus-visible { color: var(--muted); text-decoration-color: currentColor; outline: none; }
/* Log in: smaller, just above the main button at the bottom */
.mobile-menu a:not(.menu-cta):nth-last-child(2) { margin-top: auto; font-size: 17px; font-weight: 500; color: var(--muted); }
.mobile-menu a:not(.menu-cta):nth-last-child(2):hover { color: var(--text); }
.mobile-menu a.menu-cta {
  align-self: stretch; margin-top: 8px; padding: 0; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; letter-spacing: 0;
  background: var(--text); color: var(--on-text); text-decoration: none;
}
.mobile-menu a.menu-cta:hover { color: var(--on-text); opacity: .9; }
@media (max-width: 720px) {
  .menu-toggle { display: inline-flex; }
}

/* Phones: the middle menu is hidden, so switch the header to a simple row:
   logo on the left, buttons pushed to the right edge */
@media (max-width: 720px) {
  header:has(> nav) { display: flex; }
  header:has(> nav) > .actions { margin-left: auto; }
}

/* Phones: always keep the same breathing room between the header and the
   first content, also on centred pages when the screen is short */
@media (max-width: 720px) {
  main { padding-top: 32px !important; }
}

/* Cookie notice (cookies.js) */
.cookie-box {
  position: fixed; z-index: 50; left: 24px; bottom: 24px; width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - 48px); overflow-y: auto;
  background: var(--box); color: var(--text); border: 1px solid var(--box-border); border-radius: 20px;
  box-shadow: 0 24px 70px var(--shadow), 0 2px 8px var(--shadow); padding: 22px; font-size: 14px;
  animation: cookie-in .35s ease-out;
}
@keyframes cookie-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cookie-box { animation: none; } }
.cookie-box h2 { font-size: 16px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.cookie-box p { color: var(--muted); line-height: 1.55; margin: 0; }
.cookie-box p a { color: var(--text); }
.cookie-settings { display: flex; flex-direction: column; margin-top: 14px; border-top: 1px solid var(--box-border); }
.cookie-settings[hidden] { display: none; }
.cookie-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--box-border); cursor: pointer; }
.cookie-row span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cookie-row b { font-weight: 600; }
.cookie-row small { font-size: 12px; color: var(--faint); line-height: 1.4; }
.cookie-row input { width: 18px; height: 18px; accent-color: var(--accent, var(--text)); flex: none; }
.cookie-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.ck-btn { font: inherit; font-size: 14px; font-weight: 600; height: 40px; padding: 0 16px; border-radius: 10px; cursor: pointer; }
.ck-primary { background: var(--accent, var(--text)); color: var(--on-text); border: 0; }
.ck-second { background: var(--field); color: var(--text); border: 1px solid var(--field-border); }
.ck-btn:focus-visible, .ck-link:focus-visible { outline: 2px solid var(--strong-border); outline-offset: 2px; }
.ck-link { font: inherit; font-size: 14px; font-weight: 500; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 8px 4px; margin-left: auto; text-decoration: underline; text-underline-offset: 3px; }
.ck-link:hover { color: var(--text); }
@media (max-width: 720px) {
  .cookie-box { left: 16px; right: 16px; bottom: 16px; width: auto; padding: 18px; }
  .ck-btn { flex: 1 1 auto; }
  .ck-link { margin-left: 0; width: 100%; text-align: center; }
}
