/* Header / Footer / Tweaks chrome */

[data-ps-header] {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklch, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}
.ps-header-inner {
  display: flex; align-items: center; gap: 24px;
  height: 68px;
}
.ps-brand { display: flex; align-items: center; }
.ps-brand img { height: 28px; width: auto; }

/* Theme-swappable logos: render both, show the matching one.
   Default (no data-theme attribute set yet): show the dark-theme logo
   so the first paint on a dark page is correct. */
.ps-logo--light { display: none; }
:root[data-theme="light"] .ps-logo--light { display: inline-block; }
:root[data-theme="light"] .ps-logo--dark  { display: none; }

.ps-nav { display: flex; gap: 4px; margin-left: 16px; flex: 1; }
.ps-nav-link {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-2);
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.ps-nav-link:hover, .ps-nav-link.is-active { color: var(--text); background: var(--surface); }

.ps-header-right { display: flex; align-items: center; gap: 8px; }

.ps-lang { position: relative; cursor: pointer; }
.ps-lang-current {
  display: inline-flex; align-items: center;
  height: 36px; padding: 0 8px 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  border-radius: var(--r-sm);
}
.ps-lang-current::after { content: ""; }
.ps-lang-caret { color: var(--text-3); padding-right: 10px; }
.ps-lang:hover .ps-lang-current { background: var(--surface); color: var(--text); }
.ps-lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  list-style: none; margin: 0; padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  backdrop-filter: blur(12px);
  min-width: 100px;
  z-index: 80;
  opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
:root[data-theme="dark"] .ps-lang-menu { background: oklch(0.18 0.028 270); }
:root[data-theme="light"] .ps-lang-menu { background: #ffffff; }
.ps-lang.is-open .ps-lang-menu { opacity: 1; pointer-events: auto; transform: translateY(0); }
.ps-lang-menu li {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  border-radius: var(--r-sm);
  white-space: nowrap;
  min-width: 130px;
}
.ps-lang-menu li:hover { background: var(--surface-2); color: var(--text); }
.ps-lang-menu li.is-active { color: var(--accent); }
/* Make the entire row clickable: anchor fills the li with padding,
   so clicks anywhere inside the row navigate. */
.ps-lang-menu li > a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  color: inherit;
  text-decoration: none;
  border-radius: inherit;
  cursor: pointer;
}
.ps-lang-code {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-3);
  min-width: 22px;
}
.ps-lang-menu li.is-active .ps-lang-code { color: var(--accent-hi); }
.ps-lang-dash { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; }
.ps-lang-native { font-size: 13px; font-family: var(--font-sans); }

.ps-burger { display: none; }

/* ===== Mobile ===== */
@media (max-width: 880px) {
  .ps-nav { display: none; }
  .ps-burger { display: inline-flex; order: -2; margin-right: 4px; }
  .ps-brand { order: -1; }
  .ps-header-right { order: 1; margin-left: auto; }
  .ps-mobile-open .ps-nav {
    display: flex; flex-direction: column;
    position: absolute; top: 100%; left: 0; right: 0;
    padding: 18px 24px;
    background: var(--bg);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-3);
    gap: 14px;
    z-index: 50;
  }
  :root[data-theme="dark"] .ps-mobile-open .ps-nav { background: oklch(0.12 0.022 270); }
  :root[data-theme="light"] .ps-mobile-open .ps-nav { background: #ffffff; }
  .ps-header-right .btn { padding: 0 12px; }
  .ps-header-right .btn .ar { display: none; }
}
@media (max-width: 640px) {
  .ps-header-inner { padding: 0 14px; gap: 8px; }
  .ps-header-right { gap: 4px; }
  .ps-mobile-open .ps-nav { gap: 18px; }
}
@media (max-width: 420px) {
  .ps-header-right .btn { display: none; }
}

.ps-theme {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  transition: color var(--t-base), background var(--t-base), border-color var(--t-base);
}
.ps-theme .ps-theme-ico { display: inline-grid; place-items: center; line-height: 0; }
.ps-theme .ps-theme-ico svg { display: block; }
.ps-theme:hover {
  background: var(--surface);
  color: var(--text);
  border-color: color-mix(in oklch, var(--accent) 35%, var(--line));
}
.ps-theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* burger styles only — visibility handled in media queries above */
.ps-burger {
  width: 36px; height: 36px;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: var(--r-sm);
  background: transparent;
}
.ps-burger:hover { background: var(--surface); }
.ps-burger span {
  display: block;
  width: 18px; height: 1.5px;
  background: var(--text-2);
  border-radius: 2px;
  transition: transform var(--t-fast), opacity var(--t-fast);
}
.ps-mobile-open .ps-burger span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.ps-mobile-open .ps-burger span:nth-child(2) { opacity: 0; }
.ps-mobile-open .ps-burger span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

/* Footer ----------------------------------------------------------- */
[data-ps-footer] {
  position: relative;
  margin-top: var(--s-32);
  padding: var(--s-20) 0 var(--s-8);
  isolation: isolate;
  border-top: 1px solid var(--line);
  overflow: hidden;
}
[data-ps-footer]::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 50% 60% at 12% 100%,
      color-mix(in oklch, var(--glow-1) 55%, transparent) 0%,
      transparent 72%),
    radial-gradient(ellipse 55% 60% at 88% 100%,
      color-mix(in oklch, var(--glow-2) 50%, transparent) 0%,
      transparent 72%),
    radial-gradient(ellipse 80% 70% at 50% 130%,
      color-mix(in oklch, var(--glow-3) 60%, transparent) 0%,
      transparent 65%);
  filter: blur(50px) saturate(1.05);
  opacity: var(--glow-strength);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 100%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 100%);
}
:root[data-theme="light"] [data-ps-footer]::before { mix-blend-mode: multiply; filter: blur(60px) saturate(0.9); }
/* Footer grid overlay removed — glow-only background per design preference. */
.ps-footer-grid {
  display: grid;
  grid-template-columns: 1.1fr 2fr;
  gap: 64px;
  padding-bottom: var(--s-16);
}
.ps-footer-brand img { height: 32px; width: auto; }
.ps-footer-tag {
  margin-top: 16px;
  color: var(--text-3);
  max-width: 360px;
  font-size: 14px;
}
.ps-footer-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.ps-footer-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.ps-footer-cols h4 {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 14px;
  font-weight: 500;
}
.ps-footer-cols ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.ps-footer-cols a {
  font-size: 14px;
  color: var(--text-2);
  transition: color var(--t-fast);
}
.ps-footer-cols a:hover { color: var(--text); }

.ps-footer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: var(--s-6);
  border-top: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}
.ps-footer-links { display: inline-flex; gap: 18px; }
.ps-footer-links a { color: var(--text-3); transition: color var(--t-fast); }
.ps-footer-links a:hover { color: var(--text); }
.ps-status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--good);
  margin-left: 6px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--good);
}

@media (max-width: 880px) {
  .ps-footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .ps-footer-cols { grid-template-columns: repeat(2, 1fr); }
  .ps-footer-bottom { flex-direction: column; gap: 12px; align-items: flex-start; }
}
@media (max-width: 480px) {
  .ps-footer-cols { grid-template-columns: 1fr; }
}

/* Tweaks panel mobile */
@media (max-width: 480px) {
  #ps-tweaks { right: 8px; left: 8px; bottom: 8px; width: auto; }
}

/* Tweaks panel ---------------------------------------------------- */
#ps-tweaks {
  position: fixed; right: 16px; bottom: 16px; z-index: 100;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--t-base), transform var(--t-base);
}
#ps-tweaks.is-open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.ps-tweaks-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.ps-tweaks-title {
  font-family: var(--font-mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-2);
}
.ps-tweaks-close {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: 20px; line-height: 1;
  color: var(--text-3);
  border-radius: var(--r-sm);
}
.ps-tweaks-close:hover { background: var(--surface-2); color: var(--text); }
.ps-tweaks-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 18px; }
.ps-tweaks-body section { display: flex; flex-direction: column; gap: 8px; }
.ps-tweaks-body label {
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
  display: flex; justify-content: space-between;
}
.ps-num { color: var(--accent); }

.ps-seg {
  display: grid; grid-template-columns: repeat(2, 1fr);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.ps-seg-2 { grid-template-columns: repeat(4, 1fr); }
.ps-seg button {
  height: 30px; font-size: 12px;
  color: var(--text-2);
  border-radius: 4px;
  transition: background var(--t-fast), color var(--t-fast);
  font-family: var(--font-body);
}
.ps-seg button.is-on { background: var(--surface-hi); color: var(--text); box-shadow: var(--shadow-1); }
.ps-seg button:hover { color: var(--text); }

.ps-tweaks-body input[type="range"] {
  width: 100%; appearance: none; height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  outline: none;
}
.ps-tweaks-body input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
}

.ps-hue-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg,
    oklch(0.7 0.18 240),
    oklch(0.7 0.18 270),
    oklch(0.7 0.18 290),
    oklch(0.7 0.18 320));
}
