/*
  Desktop-in-a-mockup styles for the homepage (index.html).

  The OS windows are the REAL @sheru/webui SPA, themed by the OFFICIAL
  @sheru/ui engine (/embed/main.js). The engine stamps <html data-theme> and
  rewrites the official token block on :root, re-skinning every window. The
  page places a fixed-resolution desktop canvas ([data-desktop]) inside a
  hardware mockup's screen; the compositor scales it to fit. Page-level
  marketing styles live in the page and use hp-prefixed custom properties
  only, so the cycling theme never restyles the page around the device.
*/

:root {
  /* Constant content typography. */
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-copy: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  /* Constant identity — never themed. */
  --tape-fill: rgba(255, 221, 0, 0.07);
  --tape-edge: rgba(255, 221, 0, 0.13);
  --tape-ink: rgba(255, 236, 130, 0.16);

  /* Pre-JS fallback (Windows 98) for the official tokens the slogan window
     reads. The @sheru/ui engine overwrites these on :root once /embed/main.js
     boots; they only prevent a flash before it loads. */
  --window-bg: #c0c0c0;
  --window-border: none;
  --window-radius: 0px;
  --surface: #c0c0c0;
  --fg: #000000;
  --fg-muted: #404040;
  --border: #808080;
  --titlebar-bg: linear-gradient(90deg, #000080, #1084d0);
  --titlebar-fg: #ffffff;
  --titlebar-h: 22px;
  --font-ui: Tahoma, "MS Sans Serif", Geneva, Verdana, sans-serif;
  --font-size: 12px;
  --control-bg: #c0c0c0;
  --control-fg: #000000;
  --control-border: #808080;
  --control-radius: 0px;
  --control-bg-hover: #c0c0c0;
  --control-bg-active: #c0c0c0;
}

/* Desktop wallpaper per OS (keyed on the official data-theme the engine sets
   on <html>). */
[data-theme="win98"] {
  --hp-desktop-bg: #008080;
}
[data-theme="aqua"] {
  --hp-desktop-bg: radial-gradient(140% 110% at 50% 0%, #6c9ef0 0%, #2f6fde 45%, #14356f 100%);
}
[data-theme="winxp"] {
  --hp-desktop-bg: linear-gradient(180deg, #4a93d9 0%, #6fb1e3 38%, #8ec63f 46%, #5b9b34 70%, #4a8a2c 100%);
}
[data-theme="win7"] {
  --hp-desktop-bg: radial-gradient(120% 90% at 50% 110%, #2f7fd6 0%, #103e76 45%, #06203f 100%);
}
[data-theme="xfce"] {
  --hp-desktop-bg: linear-gradient(180deg, #41576b, #25323f);
}

/* ── Scrollable pages ──
   The embedded SPA injects its app-shell base stylesheet into the document
   (#sheru-base, appended after the page's own <style>), whose body rules —
   overflow hidden, themed color/font, selection off, default cursor — are
   right for an app window and wrong for a marketing page. The page opts in
   with <body class="hp-scroll">; the class outranks the injected element
   selectors no matter the order, and the page's own body.hp-scroll rule
   restores its typography. Inside the mockup windows the native feel stays. */
body.hp-scroll {
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  cursor: auto;
  -webkit-user-select: text;
  user-select: text;
}
/* Keep the website viewport scrollbar in the site chrome. The embedded SPA
   deliberately injects global, theme-specific scrollbar rules; these more
   specific root selectors stop those rules from re-skinning the page scrollbar
   while leaving every scrollbar inside the mockup windows themed. */
html.hp-scroll-root,
body.hp-scroll {
  scrollbar-color: rgba(255, 255, 255, 0.24) var(--hp-bg, #0b0f14);
  scrollbar-width: thin;
}
html.hp-scroll-root::-webkit-scrollbar,
body.hp-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html.hp-scroll-root::-webkit-scrollbar-track,
body.hp-scroll::-webkit-scrollbar-track {
  background: var(--hp-bg, #0b0f14);
  border: 0;
}
html.hp-scroll-root::-webkit-scrollbar-thumb,
html.hp-scroll-root::-webkit-scrollbar-thumb:hover,
html.hp-scroll-root::-webkit-scrollbar-thumb:active,
body.hp-scroll::-webkit-scrollbar-thumb,
body.hp-scroll::-webkit-scrollbar-thumb:hover,
body.hp-scroll::-webkit-scrollbar-thumb:active {
  background: rgba(255, 255, 255, 0.24);
  background-clip: padding-box;
  border: 3px solid var(--hp-bg, #0b0f14);
  border-radius: 999px;
  box-shadow: none;
}
html.hp-scroll-root::-webkit-scrollbar-button,
body.hp-scroll::-webkit-scrollbar-button {
  display: none;
}
html.hp-scroll-root::-webkit-scrollbar-corner,
body.hp-scroll::-webkit-scrollbar-corner {
  background: var(--hp-bg, #0b0f14);
}
/* …and inside the mockup windows, re-establish exactly the inheritance
   context the SPA's base body rule would have provided (themed color/font,
   app line-height, selection off) — otherwise window content that inherits
   from body picks up the page's pale ink and mono font. */
body.hp-scroll .embed-window {
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--font-size);
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}

/* ── The fixed-resolution desktop canvas inside the mockup screen ──
   Width/height are set inline (they mirror data-width/data-height); the
   compositor sets the scale() so it fills the screen cutout. */
.hp-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  overflow: hidden;
  background: var(--hp-desktop-bg, #008080);
}

/* ── Live @sheru/webui windows: the compositor sizes, positions and mounts
   the REAL SPA into these. ── */
.embed-window {
  position: absolute;
  border-radius: var(--window-radius);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  background: var(--window-bg);
}
/* React owns this inner mount; it fills the container, the grip sits over it. */
.embed-mount {
  position: absolute;
  inset: 0;
}
/* The SPA's window frame is position:fixed/inset:0 (it owns a native
   NSWindow); inside a compositor container it must fill the container. */
.embed-window [data-part="window"] {
  position: absolute;
}
/* Drag affordance on the titlebar (the compositor handles the drag). */
.embed-window [data-part="titlebar"] {
  cursor: grab;
}
.embed-window.grabbing,
.embed-window.grabbing [data-part="titlebar"] {
  cursor: grabbing;
}
/* True-center titlebar captions on the homepage windows (see the original
   homepage for the full rationale: a 1fr/auto/1fr grid is immune to the
   control cluster's width/padding; these windows only show short titles). */
.embed-window [data-part="titlebar"][data-title-align="center"] {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.embed-window [data-part="titlebar"][data-title-align="center"]::after {
  content: none;
}
.embed-window [data-part="titlebar"][data-title-align="center"] [data-part="title"] {
  grid-column: 2;
  justify-self: center;
  min-width: 0;
}
.embed-window [data-part="titlebar"][data-title-align="center"][data-controls-side="left"] [data-part="controls"] {
  grid-column: 1;
  justify-self: start;
}
.embed-window [data-part="titlebar"][data-title-align="center"][data-controls-side="right"] [data-part="controls"] {
  grid-column: 3;
  justify-self: end;
}
/* Bottom-right resize grip (injected + wired by the compositor). */
.resize-grip {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  z-index: 20;
  cursor: nwse-resize;
}
.embed-window.resizing {
  user-select: none;
}

/* ── Slogan window body (rendered into the official chrome by /embed) ── */
.body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.8rem 1.8rem 2rem;
  text-align: center;
  background: var(--surface);
}
.embed-window[data-win="main"] .body {
  justify-content: safe center;
  overflow-y: auto;
}
.headline {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4.4vw, 2.1rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--fg);
  text-shadow: -1.5px 0 rgba(0, 200, 255, 0.6), 1.5px 0 rgba(255, 0, 120, 0.55);
  animation: chroma 5s steps(1, end) infinite;
}
@keyframes chroma {
  0%,
  90%,
  100% {
    text-shadow: -1.5px 0 rgba(0, 200, 255, 0.6), 1.5px 0 rgba(255, 0, 120, 0.55);
    transform: translateX(0);
  }
  92% {
    text-shadow: -3px 0 rgba(0, 200, 255, 0.75), 3px 0 rgba(255, 0, 120, 0.7);
    transform: translateX(-1px);
  }
  94% {
    text-shadow: 3px 0 rgba(0, 200, 255, 0.7), -3px 0 rgba(255, 0, 120, 0.65);
    transform: translateX(1px);
  }
  96% {
    text-shadow: -2px 0 rgba(0, 200, 255, 0.7), 2px 0 rgba(255, 0, 120, 0.6);
    transform: translateX(0);
  }
}
.kana {
  margin: 0 0 1.3rem;
  font-family: "Geneva", "Verdana", "Segoe UI", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.4em;
  color: var(--fg-muted);
}
.tagline {
  margin: 0 auto 1.7rem;
  max-width: 38ch;
  font-family: var(--font-copy);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--fg-muted);
}
/* Native per-theme button (adopts the active theme's control tokens). */
.btn {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: calc(var(--font-size) + 1px);
  font-weight: 600;
  color: var(--control-fg);
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: var(--control-radius);
  box-shadow: var(--control-shadow, 0 1px 2px rgba(0, 0, 0, 0.25));
  padding: 0.55em 1.6em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn:hover {
  background: var(--control-bg-hover);
}
.btn:active {
  background: var(--control-bg-active);
  box-shadow: var(--control-shadow-active, inset 0 1px 3px rgba(0, 0, 0, 0.3));
}

/* ── In-the-Shell warning tape — CONSTANT, never themed/glitched ──
   Absolute, so it works inside the desktop canvas. */
.tape-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.tape {
  position: absolute;
  left: -30%;
  width: 160%;
  overflow: hidden;
  white-space: nowrap;
  padding: 0.5em 0;
  background: var(--tape-fill);
  border-top: 1px solid var(--tape-edge);
  border-bottom: 1px solid var(--tape-edge);
  color: var(--tape-ink);
  font-family: "Geneva", "Verdana", "Segoe UI", system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.4em;
  transform: rotate(var(--rot));
  transform-origin: center;
}
.tape__inner {
  display: inline-block;
  will-change: transform;
  animation: drift var(--dur, 90s) linear infinite;
}
.tape--rev .tape__inner {
  animation-direction: reverse;
}
.tape__inner > span {
  display: inline-block;
}
@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

/* ── Theme-swap glitch (verbatim from the original homepage) ── */
.fx-glitch {
  animation: winGlitch 0.44s ease-in-out both;
}
.fx-glitch .titlebar,
.fx-glitch .body {
  animation: rgbSplit 0.44s ease-in-out both;
}
@keyframes winGlitch {
  0%, 100% { transform: translateX(0); filter: none; opacity: 0.92; }
  12% { transform: translateX(-2px); filter: brightness(1.16) hue-rotate(8deg); opacity: 0.76; }
  24% { transform: translateX(1.5px); filter: brightness(0.9); opacity: 0.92; }
  38% { transform: translateX(-1.5px); filter: brightness(1.18) saturate(1.18); opacity: 0.72; }
  52% { transform: translateX(2px); filter: brightness(0.92) hue-rotate(-8deg); opacity: 0.9; }
  66% { transform: translateX(-1.5px); filter: brightness(1.15); opacity: 0.74; }
  80% { transform: translateX(1px); filter: none; opacity: 0.9; }
  90% { transform: translateX(-0.5px); filter: brightness(1.08); opacity: 0.84; }
}
@keyframes rgbSplit {
  0%, 100% { text-shadow: none; }
  16% { text-shadow: 3px 0 rgba(255, 0, 90, 0.78), -3px 0 rgba(0, 247, 255, 0.78); }
  40% { text-shadow: -4px 0 rgba(255, 0, 90, 0.74), 4px 0 rgba(0, 247, 255, 0.74); }
  64% { text-shadow: 3px 0 rgba(255, 0, 90, 0.7), -3px 0 rgba(0, 247, 255, 0.7); }
  84% { text-shadow: -2px 0 rgba(255, 0, 90, 0.64), 2px 0 rgba(0, 247, 255, 0.64); }
}

/* ── CRT display tube — decorative overlay for CRT-style mockups ──
   Absolute (fills whatever screen it is placed in), pointer-events none. */
.crt {
  position: absolute;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
}
.crt::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.05) 50%),
    repeating-linear-gradient(
      90deg,
      rgba(255, 0, 0, 0.01),
      rgba(0, 255, 0, 0.007) 33%,
      rgba(0, 0, 255, 0.01) 66%
    );
  background-size: 100% 3px, 5px 100%;
  mix-blend-mode: multiply;
}
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    110% 110% at 50% 50%,
    rgba(0, 0, 0, 0) 32%,
    rgba(0, 0, 0, 0.4) 70%,
    rgba(0, 0, 0, 0.92) 100%
  );
  animation: crtFlicker 5.5s steps(40) infinite;
}
.crt__roll {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 16%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.045) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: crtRoll 7s linear infinite;
}
@keyframes crtFlicker {
  0%,
  100% {
    opacity: 1;
  }
  48% {
    opacity: 0.93;
  }
  50% {
    opacity: 0.99;
  }
  52% {
    opacity: 0.95;
  }
}
@keyframes crtRoll {
  from {
    transform: translateY(-120%);
  }
  to {
    transform: translateY(720%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tape__inner {
    animation: none;
  }
  .fx-glitch,
  .fx-glitch .titlebar,
  .fx-glitch .body {
    animation: none !important;
    filter: none !important;
    opacity: 1 !important;
  }
  .headline {
    animation: none;
  }
  .crt::after {
    animation: none;
  }
  .crt__roll {
    display: none;
  }
}
