/* ATRIUM 95 — global rules, the responsive size scale, and keyframes.
   Component styling lives inline in js/, matching the design source. */

html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #1b1040; }
* { box-sizing: border-box; }

a { color: #01cdfe; }
a:hover { color: #ff71ce; }
::selection { background: #ff71ce; color: #fff; }

/* ---------------------------------------------------------------------------
   Size scale.

   The shell's chrome (icons, taskbar, Start menu, SKYLIGHT) is sized from these
   variables rather than from literals, so one media query moves the whole set
   together. Everything grows as the viewport shrinks: a 38px icon that reads
   fine under a mouse is far too small under a thumb.

   The desktop values here are already a step up from the design's originals
   (38px plates, 38px taskbar, 48px bird), which were drawn against a 1024px
   canvas and read undersized on a modern display.
   --------------------------------------------------------------------------- */
:root {
  --icon-plate: 48px;   /* the raised square behind the glyph */
  --icon-glyph: 25px;   /* the glyph character inside it */
  --icon-logo: 30px;    /* the spiral SVG that stands in for welcome.exe's glyph */
  --icon-cell: 96px;    /* column width, wide enough for the longest label */
  --icon-label: 12px;
  --icon-gap-x: 12px;
  --icon-gap-y: 18px;

  --taskbar-h: 44px;
  --taskbar-font: 13px; /* START */
  --taskbtn-font: 12px; /* one button per open window */
  --tray-font: 13px;
  --tray-icon: 17px;
  --start-swatch: 18px;

  --menu-w: 232px;
  --menu-font: 13px;
  --menu-row-pad: 6px;
  --menu-icon: 20px;   /* app art in the Start menu */
  --taskbtn-icon: 16px;

  --bird-w: 60px;
  --bird-bubble: 248px;
  --bird-font: 12px;
}

/* Large displays: the desktop has room, so take it. */
@media (min-width: 1500px) {
  :root {
    --icon-plate: 56px; --icon-glyph: 29px; --icon-logo: 35px;
    --icon-cell: 108px; --icon-label: 13px; --icon-gap-y: 20px;
    --taskbar-h: 48px; --taskbar-font: 14px; --taskbtn-font: 13px;
    --tray-font: 14px; --tray-icon: 19px; --start-swatch: 20px;
    --menu-w: 250px; --menu-font: 14px; --menu-icon: 22px; --taskbtn-icon: 18px;
    --bird-w: 72px; --bird-bubble: 268px; --bird-font: 13px;
  }
}

/* Laptops and tablets: pointers get less precise, so the chrome gets bigger. */
@media (max-width: 1100px) {
  :root {
    --icon-plate: 54px; --icon-glyph: 28px; --icon-logo: 33px;
    --icon-cell: 100px; --icon-gap-y: 20px;
    --taskbar-h: 48px; --taskbar-font: 14px; --taskbtn-font: 12px;
    --tray-icon: 18px; --start-swatch: 19px;
    --menu-w: 244px; --menu-font: 14px; --menu-row-pad: 8px; --menu-icon: 22px;
    --taskbtn-icon: 17px;
    --bird-w: 68px; --bird-bubble: 256px;
  }
}

/* Icon grid. Layout lives here rather than inline so the phone breakpoint can
   swap flex columns for a real grid; the inline `display:none` that hides the
   grid until the reveal still wins, because inline beats a stylesheet. */
[data-icons="1"] {
  display: flex;
  flex-flow: column wrap;
  align-content: flex-start;
  gap: var(--icon-gap-y) var(--icon-gap-x);
}
[data-iconplate="1"] > svg { width: var(--icon-logo); height: var(--icon-logo); }
/* The app art is pixel work drawn well above its display size, so let the browser
   resample smoothly on the way down — `pixelated` only shimmers at these ratios.
   The drop shadow gives the bare silhouettes the same lift the plates had. */
[data-icon="1"] img { filter: drop-shadow(2px 2px 0 rgba(10, 4, 40, .38)); }
[data-tray="1"] > svg { width: var(--tray-icon); height: var(--tray-icon); }
[data-bird="1"] img { width: var(--bird-w); height: auto; }

/* The Poetry and Guestbook icons both use an open-book silhouette. Keep Poetry
   at the end of the icon flow on desktop and mobile so the two are not adjacent,
   without changing the definition order used by the Start menu or taskbar. */
[data-icons="1"] [data-app="poetry"] { order: 1; }

@media (prefers-reduced-motion: reduce) {
  /* Stop the ambient loops without flattening the desktop: the one-shot reveals stay. */
  [style*="ci-bob"], [style*="ci-twinkle"], [style*="ci-shine"] { animation: none !important; }
}

/* ---------------------------------------------------------------------------
   Phones: one window at a time as a full-width sheet, and a home-screen icon
   grid — four evenly spread columns filling the width, the way a phone lays
   out apps, instead of the desktop's left-hand column stack.
   --------------------------------------------------------------------------- */
@media (max-width: 760px) {
  :root {
    --icon-plate: 58px; --icon-glyph: 30px; --icon-logo: 36px;
    --icon-label: 11px; --icon-gap-y: 18px;
    --taskbar-h: 54px; --taskbar-font: 14px; --taskbtn-font: 12px;
    --tray-font: 13px; --tray-icon: 19px; --start-swatch: 20px;
    --menu-w: 264px; --menu-font: 15px; --menu-row-pad: 10px; --menu-icon: 26px;
    --taskbtn-icon: 18px;
    --bird-w: 66px; --bird-bubble: 236px;
  }
  [data-icons="1"] {
    position: static !important;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 14px 0 6px !important;
    padding: 0 10px;
    gap: var(--icon-gap-y) 6px;
  }
  /* The desktop column width would blow out a four-up grid track. */
  [data-icon="1"] { width: auto !important; }
  [data-iconlabel="1"] {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
  }
  /* Skyler perches bottom-right above the taskbar, and on a phone a window is
     the full width of the screen, so without this every window runs its last
     40-60px underneath him. On the desktop that corner is empty wallpaper; here
     it is wherever the footer buttons live, which is how the projects.exe
     wizard ended up with Next > behind a toucan.

     Derived from --bird-w rather than fixed, so the narrow-phone and landscape
     breakpoints below get the right clearance from their own bird size: the art
     is 78/66 as tall as it is wide, it sits 12px above the taskbar, and the 46px
     term already includes a 36px gap this only has to make up the difference on. */
  :root { --bird-clear: calc(var(--bird-w) * 1.18 - 18px); }
  [data-win="1"] {
    left: 6px !important;
    top: 10px !important;
    width: calc(100vw - 12px) !important;
    height: auto !important;
    max-height: calc(100dvh - var(--taskbar-h) - 46px - var(--bird-clear)) !important;
    overflow: auto !important;
  }
  [data-grip="1"] { display: none !important; }
  [data-scroll="1"] { max-height: none !important; }
  /* A window that claims the sheet's height and scrolls a region inside itself
     is a desktop shape. Here the frame is already height:auto with its own
     max-height and overflow, so a child still holding flex:1 just squeezes one
     region down to its min-height and hides the content. Everything in a
     data-fill chain takes its natural height and lets the frame do the
     scrolling. The hosted games and the visualizer are untouched: they get an
     explicit full-height window below and genuinely do fill it. */
  [data-fill="1"] {
    flex: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  [data-fill="1"] [data-scroll="1"] {
    flex: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  /* The poetry reader is intentionally two different editions. Desktop keeps a
     controlled facing-page stage; phone reading is the semantic, image-then-full-
     poem document and must let the window frame own the one vertical scroll. */
  [data-poetry-desktop="1"] { display: none !important; }
  [data-poetry-mobile="1"] { display: block !important; }
  [data-poetry-mobile="1"] [data-poetry-illustration="1"] {
    background: #fff;
  }
  /* Skyler deliberately disappears while Poetry is open on a phone, so this
     reader alone can reclaim the vertical clearance normally kept for him. */
  [data-win="1"][data-winid="poetry"] {
    max-height: calc(100dvh - var(--taskbar-h) - 46px) !important;
  }
  /* The Poetry window itself owns mobile scrolling. Pin its Win95 title bar so
     the close box remains available as a reader moves through a long poem. */
  [data-win="1"][data-winid="poetry"] [data-titlebar="1"] {
    position: sticky;
    top: 0;
    z-index: 3;
    box-shadow: 0 2px 0 rgba(0,0,0,.28);
  }
  [data-close="1"] { width: 34px !important; height: 30px !important; font-size: 17px !important; }
  [data-artgrid="1"] { grid-template-columns: repeat(2, 1fr) !important; }
  /* Embedded games (hosted iframes, Blip-Blupper) want every pixel of the sheet
     rather than shrinking to their content, unlike every other window here. */
  [data-win="1"][data-winid="cavern"],
  [data-win="1"][data-winid="alate"],
  [data-win="1"][data-winid="peg"],
  [data-win="1"][data-winid="game"] {
    height: calc(100dvh - var(--taskbar-h) - 46px - var(--bird-clear)) !important;
  }
}

/* Narrow phones: four columns still fit, but the plates have to come back in. */
@media (max-width: 360px) {
  :root {
    --icon-plate: 52px; --icon-glyph: 27px; --icon-logo: 32px;
    --icon-label: 10px; --icon-gap-y: 16px;
    --taskbar-h: 52px; --bird-w: 60px; --bird-bubble: 220px;
  }
}

/* Short viewports — a phone held sideways, mostly. Height is the scarce axis
   there, so the taskbar and icons give some of the bump back. */
@media (max-height: 520px) {
  :root {
    --icon-plate: 42px; --icon-glyph: 22px; --icon-logo: 26px;
    --icon-gap-y: 10px; --taskbar-h: 40px; --taskbar-font: 12px;
    --tray-icon: 15px; --start-swatch: 16px;
    --menu-row-pad: 4px; --bird-w: 52px;
  }
}

@keyframes ci-eq     { 0%, 100% { transform: scaleY(.2); } 50% { transform: scaleY(1); } }
@keyframes ci-blink  { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes ci-shine  { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
@keyframes ci-fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes ci-twinkle{ 0%, 100% { opacity: .15; } 50% { opacity: 1; } }
@keyframes ci-drift  { 0% { transform: translateY(0); } 100% { transform: translateY(-320px); } }
@keyframes ci-bob    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
