/* ==========================================================================
   PLANET FORGE  ·  stylesheet
   --------------------------------------------------------------------------
   DESKTOP  #view fills the window; #panel is a 340 px column at the left.
   PHONE (max-width 760px, or a short landscape touch screen): #dock at the
   base; #panel is a bottom sheet above it in portrait, a right drawer in
   landscape. main.js reads the panel box to frame the planet in the clear
   area (the principal point shift of the view).
   (pointer:coarse) gets 44 px targets, 12 px small text, and 16 px in
   number and select boxes (iOS Safari zooms the page on focus below 16 px).
   #mapView sits over the sheet on a phone (z-index 7), so a tapped map
   shows in full.
   grep -n 'PHONE'      dock + sheet       grep -n 'LANDSCAPE'  right drawer
   grep -n 'TOUCH'      coarse pointer sizes
   ========================================================================== */
:root {
  --bg: #07090d; --bg2: rgba(14, 18, 26, 0.92); --line: rgba(255, 255, 255, 0.09);
  --ink: #e6e9ee; --dim: #8b94a3; --acc: #ffb45a; --acc2: #7fc4ff;
  --panel-w: 340px; --dock-h: 0px;
  font: 400 13px/1.4 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view.drag { cursor: grabbing; }
/* an element with the hidden attribute stays hidden even when a rule
   below gives it a display (#nogpu, #mapView): the message showed on every
   browser, also with WebGPU */
[hidden] { display: none !important; }
#nogpu { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; text-align: center; padding: 24px; padding-left: calc(var(--panel-w) + 24px); color: var(--dim); }
#nogpu b { color: var(--ink); font-size: 15px; }

#top { position: fixed; top: 0; left: var(--panel-w); right: 0; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; font-size: 12px; letter-spacing: 0.04em; }
#clock { flex: none; color: var(--acc); font-variant-numeric: tabular-nums; }
.presets.rates { margin: 2px 0 6px; } .presets.rates button { padding: 6px 2px; font-size: 11px; }
#top .brand { color: var(--dim); } #top .sep { color: #444; } #top .name { font-weight: 600; }
#status { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font-variant-numeric: tabular-nums; }
#prog { position: fixed; top: 0; left: var(--panel-w); right: 0; height: 2px; }
#prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--acc2), var(--acc)); transition: width 0.15s, opacity 0.6s; }

#panel { position: fixed; top: 0; left: 0; bottom: 0; width: var(--panel-w); background: var(--bg2); border-right: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; flex-direction: column; z-index: 5; }
#tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
#tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--dim); padding: 12px 0 10px; font: inherit; font-weight: 500; cursor: pointer; }
#tabs button.on { color: var(--ink); border-bottom-color: var(--acc); }
#panel section { display: none; padding: 14px 16px 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
#panel section.on { display: block; }
#panel h4 { margin: 16px 0 6px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
details { border-top: 1px solid var(--line); padding: 6px 0; }
details > summary { cursor: pointer; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); font-weight: 600; padding: 6px 0; list-style: none; }
details > summary::before { content: '▸ '; } details[open] > summary::before { content: '▾ '; }

button, select, input[type=number] { font: inherit; color: var(--ink); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; }
button { cursor: pointer; } button:hover { border-color: rgba(255, 255, 255, 0.25); }
button.primary { background: var(--acc); color: #1a1206; border-color: var(--acc); font-weight: 600; }
button.wide { width: 100%; margin-top: 12px; }
.seg { display: flex; gap: 4px; margin-bottom: 10px; }
.seg button { flex: 1; } .seg button.on { border-color: var(--acc); color: var(--acc); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.presets button { padding: 8px 4px; font-size: 12px; } .presets button.on { border-color: var(--acc); background: rgba(255, 180, 90, 0.12); }
.blurb { color: var(--dim); font-size: 12px; min-height: 2.8em; margin: 10px 0; }
.note { color: var(--dim); font-size: 11.5px; margin: 6px 0; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; } .row.wrap { flex-wrap: wrap; }
.row label { width: 40px; color: var(--dim); } .row input, .row select { flex: 1; min-width: 0; }
.ctl { margin: 6px 0 8px; }
.ctl label { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }
.ctl output { color: var(--ink); font-variant-numeric: tabular-nums; }
.ctl input[type=range] { width: 100%; margin: 3px 0 0; accent-color: var(--acc); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; color: var(--dim); }
.mapgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mapgrid figure { margin: 0; cursor: pointer; }
.mapgrid canvas { width: 100%; aspect-ratio: 2 / 1; display: block; border-radius: 4px; border: 1px solid var(--line); background: #111; image-rendering: auto; }
.mapgrid figcaption { display: flex; justify-content: space-between; gap: 4px; font-size: 11px; margin-top: 3px; }
.mapgrid figcaption span { color: var(--dim); }
.mapgrid figcaption button { padding: 1px 6px; font-size: 11px; }
label.file { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; cursor: pointer; background: rgba(255, 255, 255, 0.05); }
label.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

#mapView { position: fixed; inset: 0; left: var(--panel-w); z-index: 4; background: rgba(5, 6, 9, 0.96); display: flex; flex-direction: column; }
#mapView header { display: flex; gap: 10px; align-items: center; padding: 10px 14px; }
#mapView header span { color: var(--dim); margin-right: auto; }
#mvCanvas { flex: 1; min-height: 0; width: 100%; object-fit: contain; }

#dock, #sheetGrip { display: none; }

/* PHONE: matches PHONE_Q in main.js. */
@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  :root { --panel-w: 0px; --dock-h: calc(58px + env(safe-area-inset-bottom)); }
  #top { left: 0; padding: env(safe-area-inset-top) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left)); height: calc(40px + env(safe-area-inset-top)); }
  #top .brand, #top .sep { display: none; }
  #prog { left: 0; }
  #nogpu { padding-left: 24px; }
  #dock { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--dock-h); padding: 6px 10px env(safe-area-inset-bottom); gap: 6px; background: var(--bg2); border-top: 1px solid var(--line); z-index: 6; }
  #dock button { flex: 1; height: 44px; border-radius: 10px; }
  #dock button.on { border-color: var(--acc); color: var(--acc); }
  #dock #dockDice { flex: 0 0 52px; font-size: 18px; }
  #dock #dockRate { flex: 0 0 64px; font-size: 11px; font-variant-numeric: tabular-nums; }
  #tabs { display: none; }
  #panel { top: auto; left: 0; right: 0; bottom: var(--dock-h); width: auto; height: 46vh; height: 46dvh; border-right: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; transform: translateY(calc(100% + var(--dock-h))); transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1); }
  #panel.open { transform: none; }
  #sheetGrip { display: flex; justify-content: center; align-items: center; height: 32px; flex: none; cursor: pointer; }
  #sheetGrip span { width: 44px; height: 5px; border-radius: 3px; background: var(--dim); opacity: 0.5; }
  #mapView { left: 0; bottom: var(--dock-h); z-index: 7; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
  #mapView header { flex-wrap: wrap; gap: 6px 10px; }
  #mapView header span { order: 3; flex: 1 0 100%; margin-right: 0; font-size: 12px; }
  #mapView header button:first-of-type { margin-left: auto; }
  #panel section { padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
  .presets { grid-template-columns: repeat(3, 1fr); }
}
/* LANDSCAPE phone: the panel is a right drawer, the dock a tab at the left. */
@media (max-height: 520px) and (pointer: coarse) and (orientation: landscape) {
  body:has(#panel.open) #top { right: min(360px, 48vw); }
  #panel { top: 0; left: auto; right: 0; width: min(360px, 48vw); height: auto; bottom: var(--dock-h); border-radius: 14px 0 0 0; transform: translateX(105%); }
  #dock { right: auto; width: min(440px, 56vw); border-radius: 0 14px 0 0; }
}
/* TOUCH: any coarse pointer, tablets too. */
@media (pointer: coarse) {
  button, select, input[type=number] { min-height: 44px; }
  select, input[type=number] { font-size: 16px; }
  .ctl input[type=range] { height: 40px; }
  .mapgrid figcaption button { min-height: 44px; min-width: 52px; }
  .mapgrid figcaption, .note, #panel h4, details > summary { font-size: 12px; }
  details > summary { display: flex; align-items: center; min-height: 44px; padding: 0; }
  .toggles label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
  .toggles input { width: 20px; height: 20px; }
  label.file { display: inline-flex; align-items: center; min-height: 44px; }
  #sheetGrip { height: 44px; }
}
html.sn-saver #panel, html.sn-saver #dock, html.sn-saver #top, html.sn-saver #prog, html.sn-saver #mapView, html.sn-saver #sn-wishlist-chip { display: none !important; }
html.sn-saver #view { cursor: none; }

/* randomize: mode buttons, lock rows (lock box, group name, dice) */
.seg.small button { padding: 6px 2px; font-size: 11.5px; }
.locks { display: grid; gap: 4px; margin: 6px 0 4px; }
.locks label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.locks label span { flex: 1; }
.locks label button { padding: 2px 8px; font-size: 11px; }

/* studio gallery: one card per render; a checker shows transparency */
.stgallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.stgallery figure { margin: 0; }
.stgallery canvas { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; border-radius: 4px; border: 1px solid var(--line); background: #050609; }
.stgallery figure.alpha canvas { background: repeating-conic-gradient(#222 0 25%, #333 0 50%) 0 0 / 16px 16px; }
.stgallery figcaption { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 11px; margin-top: 3px; }
.stgallery figcaption span { flex: 1 1 100%; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stgallery figcaption b { flex: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.stgallery figcaption button { padding: 1px 6px; font-size: 11px; }
/* seven dock buttons fit a 360 px phone */
@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  #dock { gap: 4px; padding-left: 6px; padding-right: 6px; }
  #dock button[data-tab] { min-width: 0; padding: 0 2px; font-size: 11.5px; }
  #dock #dockDice { flex-basis: 44px; } #dock #dockRate { flex-basis: 56px; }
}
