/* =========================================================================
 * app.css — Adobe-style "creative suite" shell for The Grey Mind editor.
 * Layered OVER editor.css (which still styles the slide internals, the form
 * controls, the .mini grids, .pillars, .slide-list, .fmtbar and the ce-* bits).
 * This file only owns the application FRAME: the 5-zone grid, the options bar,
 * the tool rail, the right dock + panels, the canvas workspace + rulers, and
 * the bottom status bar.
 * ========================================================================= */

:root {
  /* layout metrics */
  --opt-h:     46px;      /* options bar height */
  --rail-w:    54px;      /* tool rail width    */
  --status-h:  28px;      /* status bar height  */
  --ruler:     22px;      /* ruler thickness    */
  --dock-w:    352px;     /* right dock width (JS-resizable) */
  /* neutral, flattened chrome on top of the brand-green tokens from editor.css */
  --chrome-1:  #141816;   /* bars / rail / dock background       */
  --chrome-2:  #1b201d;   /* raised: panel headers, tool buttons */
  --hair:      #242b27;   /* hairline borders                    */
  --hair-2:    #323a35;   /* stronger borders / active           */
  --pit:       #090b0a;   /* workspace behind the slide          */
  --ruler-bg:  #0f1311;
}

/* ---- custom scrollbars for the whole shell (thin, themed, hover-bright) ---- */
.pbody, .viewport, .layers, .slide-list, details .body, .dock {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.16) transparent;
}
.pbody::-webkit-scrollbar, .viewport::-webkit-scrollbar, .layers::-webkit-scrollbar,
.slide-list::-webkit-scrollbar, details .body::-webkit-scrollbar {
  width: 11px; height: 11px;
}
.pbody::-webkit-scrollbar-track, .viewport::-webkit-scrollbar-track, .layers::-webkit-scrollbar-track,
.slide-list::-webkit-scrollbar-track, details .body::-webkit-scrollbar-track { background: transparent; }
.pbody::-webkit-scrollbar-thumb, .viewport::-webkit-scrollbar-thumb, .layers::-webkit-scrollbar-thumb,
.slide-list::-webkit-scrollbar-thumb, details .body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.13);
  border-radius: 999px;
  border: 3px solid transparent;          /* padding so the thumb reads slim */
  background-clip: padding-box;
}
.pbody::-webkit-scrollbar-thumb:hover, .viewport::-webkit-scrollbar-thumb:hover,
.layers::-webkit-scrollbar-thumb:hover, .slide-list::-webkit-scrollbar-thumb:hover,
details .body::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.30);
  background-clip: padding-box;
}
.pbody::-webkit-scrollbar-corner, .viewport::-webkit-scrollbar-corner { background: transparent; }

/* ---- 5-zone application grid (overrides editor.css body grid) ---- */
html, body { height: 100%; }
body {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--dock-w);
  grid-template-rows: var(--opt-h) 1fr var(--status-h);
  grid-template-areas:
    "opt   opt    opt"
    "rail  canvas dock"
    "status status status";
  height: 100vh;
  overflow: hidden;
  background: var(--pit);
}

/* ===================== options bar (top) ===================== */
.optbar {
  grid-area: opt;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: var(--chrome-1);
  border-bottom: 1px solid var(--hair);
  z-index: 30;
}
.optbar .brand { display: flex; align-items: center; gap: 9px; padding-right: 4px; }
.optbar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.optbar .brand .mark { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--text); white-space: nowrap; }
.optbar .vsep { width: 1px; height: 22px; background: var(--hair-2); margin: 0 2px; flex: 0 0 auto; }
.optbar .spacer { flex: 1; }
.optbar .lbl { font-size: 12px; color: var(--muted); white-space: nowrap; }
.optbar .lbl strong { color: var(--text); font-variant-numeric: tabular-nums; }
.optbar .chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.optbar button { padding: 7px 11px; }
.optbar select { width: auto; padding: 7px 9px; }
.optbar .nav { display: flex; align-items: center; gap: 4px; }
.optbar .nav button { padding: 6px 10px; }

/* ===================== tool rail (left) ===================== */
.toolrail {
  grid-area: rail;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0;
  background: var(--chrome-1);
  border-right: 1px solid var(--hair);
  z-index: 20;
}
.toolrail .tool {
  width: 38px; height: 38px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  font-size: 17px; line-height: 1; color: var(--muted); cursor: pointer; position: relative;
}
.toolrail .tool:hover { background: var(--chrome-2); color: var(--text); border-color: var(--hair); }
.toolrail .tool.active { background: rgba(47,111,79,.18); border-color: var(--accent); color: var(--text); }
.toolrail .rsep { width: 26px; height: 1px; background: var(--hair-2); margin: 5px 0; }
.toolrail .spacer { flex: 1; }

/* add-slide "shapes" flyout */
.toolrail .flyout-wrap { position: relative; }
.toolrail .flyout {
  position: absolute; left: 46px; top: 0; z-index: 50;
  display: none; flex-direction: column; gap: 3px; padding: 6px;
  background: var(--chrome-1); border: 1px solid var(--hair-2); border-radius: 11px;
  box-shadow: var(--shadow); min-width: 168px;
}
.toolrail .flyout.show { display: flex; }
.toolrail .flyout button { width: 100%; text-align: left; padding: 8px 11px; }

/* ===================== canvas workspace (centre) ===================== */
.workspace {
  grid-area: canvas;
  position: relative;
  display: grid;
  grid-template-columns: var(--ruler) 1fr;
  grid-template-rows: var(--ruler) 1fr;
  background: var(--pit);
  overflow: hidden;
}
.ruler-corner { background: var(--ruler-bg); border-right: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.ruler-h { border-bottom: 1px solid var(--hair); }
.ruler-v { border-right: 1px solid var(--hair); }
.ruler-h, .ruler-v { display: block; background: var(--ruler-bg); }
.viewport { position: relative; overflow: auto; }
/* flex stage that is always >= viewport so margin:auto centres when small and
   the top-left stays reachable when the slide is larger (zoomed in). */
.canvas-stage { display: flex; min-width: 100%; min-height: 100%; padding: 28px; box-sizing: border-box; }
.canvas-sizer { margin: auto; position: relative; flex: 0 0 auto; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.viewport.panning, .viewport.panning * { cursor: grabbing !important; }
.viewport.can-pan { cursor: grab; }

/* #preview is scaled here (transform), origin top-left; editor.css keeps the
   1080×1350 .slide rules. */
#preview { transform-origin: top left; }
#preview.tool-text.ce-on .ce-block { cursor: text; }

/* floating zoom controls, bottom-right of the workspace */
.zoombar {
  position: absolute; right: 14px; bottom: 14px; z-index: 15;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--chrome-1); border: 1px solid var(--hair-2); border-radius: 11px;
  box-shadow: var(--shadow);
}
.zoombar button { padding: 5px 9px; font-size: 13px; }
.zoombar .pct { min-width: 50px; text-align: center; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; cursor: pointer; padding: 5px 4px; }

/* ===================== right dock ===================== */
.dock {
  grid-area: dock;
  display: flex; flex-direction: column;
  background: var(--chrome-1);
  border-left: 1px solid var(--hair);
  overflow: hidden;
  position: relative;
}
.dock-resize { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 40; }
/* Each panel gets a proportional share of the dock height and scrolls inside its
   own body — so Layers + Slides stay reachable no matter how long Properties is.
   Collapsing a panel (click its header) hands its space back to the others. */
.panel { display: flex; flex-direction: column; border-bottom: 1px solid var(--hair); min-height: 0; }
.panel.grow-2 { flex: 2 1 0; }            /* Properties — the tall one */
.panel.grow-1 { flex: 1 1 0; }            /* Layers, Slides */
.panel.collapsed { flex: 0 0 auto; }
.panel > .phead {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 10px 12px; background: var(--chrome-2);
  font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  flex: 0 0 auto; border-bottom: 1px solid var(--hair);
}
.panel > .phead:hover { color: var(--text); background: #20261f; }
.panel > .phead .tw { transition: transform .15s ease; font-size: 9px; color: var(--muted); }
.panel.collapsed > .phead .tw { transform: rotate(-90deg); }
.panel > .phead .hic { font-size: 13px; line-height: 1; filter: saturate(.85); }
.panel > .phead .grow { flex: 1; }
.panel > .phead .count { font-weight: 500; letter-spacing: 0; color: var(--muted); text-transform: none; }

/* ---- Properties sub-sections: icon + name + hint, consistent & collapsible ---- */
.pbody details.sect { margin-bottom: 9px; }
.pbody details.sect > summary {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 13px; text-transform: none; letter-spacing: .01em;
  font-size: 12.5px; font-weight: 600; color: var(--text);
}
.pbody details.sect > summary .ic { font-size: 14px; line-height: 1; width: 18px; text-align: center; flex: 0 0 auto; filter: saturate(.85); }
.pbody details.sect > summary .snm { flex: 0 0 auto; }
.pbody details.sect > summary .shint {
  flex: 1 1 auto; min-width: 0; text-align: right; margin-right: 6px;
  font-size: 10.5px; font-weight: 500; color: var(--muted); letter-spacing: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pbody details.sect[open] > summary { border-bottom: 1px solid var(--hair); margin-bottom: 4px; }
.pbody details.sect[open] > summary .shint { opacity: .6; }
.panel > .pbody { overflow-y: auto; padding: 14px 14px 18px; flex: 1 1 auto; min-height: 0; }
.panel.collapsed > .pbody { display: none; }

/* tighten the inherited sidebar h3s when used as group labels inside a panel */
.pbody h3 { margin: 18px 0 9px; }
.pbody h3:first-child { margin-top: 0; }
/* let the Slides panel body own the scroll (no nested scrollbar from editor.css) */
.dock .slide-list { max-height: none; overflow: visible; }

/* ===================== layers panel ===================== */
.layers { display: flex; flex-direction: column; gap: 2px; }
.layer {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--text);
}
.layer:hover { background: var(--chrome-2); }
.layer.active { border-color: var(--accent); background: rgba(47,111,79,.14); }
.layer.empty .lname { color: var(--muted); font-style: italic; }
.layer.chrome .lname { color: var(--muted); }
.layer .eye {
  flex: 0 0 auto; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--muted);
}
.layer .eye:hover { background: var(--hair); color: var(--text); }
.layer.hidden { opacity: .5; }
.layer.hidden .lname { text-decoration: line-through; }
.layer .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .lkind { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ===================== status bar (bottom) ===================== */
.statusbar {
  grid-area: status;
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  background: var(--chrome-1);
  border-top: 1px solid var(--hair);
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.statusbar .si strong { color: var(--text); font-weight: 500; }
.statusbar .spacer { flex: 1; }

/* ===================== icons (single-colour line set) ===================== */
.ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; color: currentColor; flex: 0 0 auto; }
.ico svg { display: block; }
/* compact square icon buttons (nav · undo/redo · zoom) */
.iconbtn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 9px; line-height: 0; }
.iconbtn .ico { color: var(--muted); transition: color .15s ease; }
.iconbtn:hover .ico { color: var(--text); }
/* tool-rail glyphs inherit the tool's colour state */
.toolrail .tool .ico { color: inherit; }
/* panel-header icons */
.panel > .phead .hic { color: var(--muted); }
.panel > .phead:hover .hic { color: var(--text); }
.panel > .phead .tw { color: var(--muted); }
/* properties section icons — muted, brightening to the brand accent when open */
.pbody details.sect > summary .ic { color: var(--muted); transition: color .18s ease; }
.pbody details.sect > summary:hover .ic { color: var(--text); }
.pbody details.sect[open] > summary .ic { color: var(--accent-hover); }
/* layers eye */
.layer .eye .ico { color: inherit; }
.layer .eye.off { color: #6f7b75; }

/* section disclosure: replace the +/– with a rotating chevron (micro-interaction) */
.pbody details.sect > summary::after {
  content: ''; float: none; flex: 0 0 auto; width: 7px; height: 7px; margin-left: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .22s cubic-bezier(.4,0,.2,1); opacity: .8;
}
.pbody details.sect[open] > summary::after { transform: rotate(45deg); }

/* ===================== micro-interactions ===================== */
@keyframes sectIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
@keyframes flyIn  { from { opacity: 0; transform: translateX(-7px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes layerIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.pbody details.sect[open] > .body { animation: sectIn .22s cubic-bezier(.4,0,.2,1); }
.toolrail .flyout.show { animation: flyIn .16s cubic-bezier(.4,0,.2,1); }
.layer { transition: background .16s ease, border-color .16s ease, transform .12s ease, opacity .2s ease; will-change: transform; }
.layer:hover { transform: translateX(2px); }
.layer.active { animation: layerIn .18s ease; }
.toolrail .tool { transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease; }
.toolrail .tool:active { transform: scale(.9); }
.toolrail .tool.active .ico { animation: layerIn .2s ease; }
.layer .eye, .pillar, .slide-item { transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease; }
.slide-item:hover { transform: translateX(2px); }
.zoombar button, .iconbtn { transition: background .15s ease, border-color .15s ease, transform .08s ease; }
.zoombar button:active { transform: scale(.92); }
.phead .tw, .phead .hic, .badge { transition: color .15s ease, transform .15s ease; }
/* gentle fade-in for the whole app on first paint */
@keyframes appIn { from { opacity: 0; } to { opacity: 1; } }
body { animation: appIn .25s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ===================== responsive: collapse dock under 1100px ===================== */
@media (max-width: 1100px) {
  body { grid-template-columns: var(--rail-w) 1fr 0; }
  .dock { position: fixed; top: var(--opt-h); right: 0; bottom: var(--status-h); width: var(--dock-w);
          transform: translateX(100%); transition: transform .2s ease; box-shadow: var(--shadow); z-index: 45; }
  body.dock-open .dock { transform: translateX(0); }
}
