/* App — 3D page (2026-12-03 restyle: Projeto Interativo look; tokens, buttons and the loading gate are in theme.css) */
:root {
  /* safe areas: the real ones on phones; ?mobile=1 (phone mock-ups, e.g. the sales-site hero) fakes an iPhone's top inset so the
     Dynamic Island never covers the buttons (app.js sets --mock-top) */
  --st: max(env(safe-area-inset-top), var(--mock-top, 0px)); --sb: max(env(safe-area-inset-bottom), var(--mock-bottom, 0px));
  --sl: env(safe-area-inset-left); --sr: env(safe-area-inset-right);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { padding: 10px 14px; min-height: 44px; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
#bar { position: fixed; top: calc(12px + var(--st)); right: calc(12px + var(--sr)); display: flex; gap: 8px; z-index: 3; }
#btn-mode { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px 9px 11px; }
#btn-mode .i-walk, body:not(.walk) #btn-mode .i-fly { display: none; }
body:not(.walk) #btn-mode .i-walk { display: block; }
#btn-full, #btn-menu { padding: 10px 12px; display: flex; align-items: center; }
#btn-hd { font: 700 13px var(--mono); letter-spacing: 0.06em; min-width: 52px; }
#btn-hd.busy { opacity: 0.6; cursor: progress; }
#btn-full .leave, body.full #btn-full .enter { display: none; }
body.full #btn-full .leave { display: inline; }

/* animated icons: walking legs/arms, paper plane bobbing with its trail */
.i-walk .leg-a, .i-walk .arm-b { transform-box: view-box; transform-origin: 11px 13px; animation: swing 0.9s ease-in-out infinite alternate; }
.i-walk .leg-b, .i-walk .arm-a { transform-box: view-box; transform-origin: 11px 13px; animation: swing 0.9s ease-in-out infinite alternate-reverse; }
.i-walk .arm-a, .i-walk .arm-b { transform-origin: 11.6px 8.4px; }
@keyframes swing { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
.i-fly .plane { animation: bob 2.4s ease-in-out infinite; }
.i-fly .trail { stroke-dasharray: 2 3; animation: trail 1s linear infinite; }
@keyframes bob { 50% { transform: translate(1px, -1.5px); } }
@keyframes trail { to { stroke-dashoffset: -10; } }
@media (prefers-reduced-motion: reduce) { .i-walk *, .i-fly * { animation: none !important; } }

/* ---------- options panel ---------- */
#menu { position: fixed; top: calc(68px + var(--st)); right: calc(12px + var(--sr)); z-index: 3;
  width: 260px; padding: 12px; max-height: calc(100vh - 90px - var(--st)); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
  display: flex; flex-direction: column; gap: 4px; }
#menu label { display: flex; align-items: center; gap: 10px; min-height: 38px; cursor: pointer; font-weight: 500; }
#menu input[type=checkbox] { width: 18px; height: 18px; }
#menu .group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
#menu .group .title { width: 100%; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
#places { display: flex; flex-wrap: wrap; gap: 6px; }
#menu .group button { padding: 7px 11px; min-height: 36px; font-size: 13.5px; box-shadow: none; background: rgba(255, 255, 255, 0.04); }
#menu .group button:hover { background: var(--accent-soft); border-color: rgba(240, 179, 35, 0.4); }
#menu .group button.on { background: var(--accent-soft); border-color: rgba(240, 179, 35, 0.6); color: var(--accent); }
#menu label.slider { flex-direction: column; align-items: stretch; gap: 2px; width: 100%; min-height: 0; cursor: default; }
#menu label.slider b { font: 600 12px var(--mono); color: var(--accent); }
#menu input[type=range] { width: 100%; height: 28px; margin: 0; touch-action: pan-y; }

/* ---------- link options help: small "?" circle in the corner ---------- */
body.touch.walk #btn-help { bottom: calc(96px + var(--sb)); right: calc(28px + var(--sr)); }   /* above "Atravessar" */
body.vitrine #btn-help { display: none; }   /* showcase embeds stay clean */

/* ---------- hint ---------- */
#hint { position: fixed; left: 50%; bottom: calc(14px + var(--sb)); transform: translateX(-50%); margin: 0; z-index: 2;
  max-width: calc(100vw - 24px); padding: 9px 14px; border-radius: 12px; background: rgba(18, 19, 23, 0.8); border: 1px solid var(--line); color: var(--ink);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font-size: 13px; text-align: center; pointer-events: none; }

/* ---------- touch controls: shown only on touch devices while walking ---------- */
#stick, #btn-ghost { display: none; }
body.touch.walk #stick { display: block; }
body.touch.walk #btn-ghost { display: inline-flex; }
body.touch #hint { bottom: auto; top: calc(68px + var(--st)); left: calc(12px + var(--sl)); transform: none; max-width: calc(100vw - 260px); text-align: left; }
#stick { position: fixed; left: calc(22px + var(--sl)); bottom: calc(26px + var(--sb)); z-index: 2;
  width: 132px; height: 132px; border-radius: 50%; background: rgba(18, 19, 23, 0.28); border: 2px solid rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92); box-shadow: 0 0 0 3px var(--accent), 0 2px 10px rgba(0, 0, 0, 0.35); pointer-events: none; }
#btn-ghost { position: fixed; right: calc(22px + var(--sr)); bottom: calc(40px + var(--sb)); z-index: 2; align-items: center; gap: 7px;
  border-radius: 24px; padding: 10px 14px 10px 11px; font-size: 14px; }

/* ---------- minimap (top left): round map inside a compass ring, plan button on its rim ---------- */
#minimap { position: fixed; top: calc(12px + var(--st)); left: calc(12px + var(--sl)); z-index: 2; width: 184px; height: 184px; }
#mm-canvas { display: block; width: 100%; height: 100%; border-radius: 50%; cursor: crosshair; touch-action: none;
  box-shadow: 0 0 0 1px rgba(240, 179, 35, 0.35), 0 6px 20px rgba(0, 0, 0, 0.45); }
#mm-plan { position: absolute; right: 0; bottom: 0; width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; }
body.touch #minimap { width: 136px; height: 136px; }
body.touch #minimap:not([hidden]) ~ #hint { left: calc(160px + var(--sl)); max-width: calc(100vw - 172px); }
body.walk #view { cursor: grab; }
body.walk #view:active { cursor: grabbing; }

/* phones (user 2026-12-03): the mode button is icon-only (plane / walker), so it never covers the minimap */
@media (max-width: 600px) { #btn-mode .lbl { display: none; } #btn-mode { padding: 10px 12px; } }

/* ---------- room card in the 3D (2026-12-04): chip under the minimap + card, like the plan's Selecionar ---------- */
#room-chip { position: fixed; top: calc(206px + var(--st)); left: calc(12px + var(--sl)); z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  max-width: 184px; padding: 7px 11px; border-radius: 12px; background: var(--panel); border: 1px solid rgba(63, 163, 122, 0.7); text-align: left;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: rc-in 0.25s ease-out; }
#room-chip b { font-size: 13px; font-weight: 700; line-height: 1.2; }
#room-chip span { font: 500 11px var(--mono); color: var(--mute); }
#minimap[hidden] ~ #room-chip, #minimap[hidden] ~ #room3d { top: calc(64px + var(--st)); }
body.touch #room-chip { top: calc(158px + var(--st)); max-width: 136px; }
#room3d { position: fixed; top: calc(206px + var(--st)); left: calc(12px + var(--sl)); z-index: 3; width: min(340px, calc(100vw - 24px)); max-height: calc(100vh - 222px - var(--st));
  overflow: auto; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7); animation: rc-in 0.2s ease-out; }
body.touch #room3d { top: calc(158px + var(--st)); max-height: calc(100vh - 174px - var(--st)); }
#room3d .x { position: absolute; top: 6px; right: 6px; min-height: 34px; padding: 2px 12px; font-size: 18px; line-height: 1; box-shadow: none; }
#room3d h2 { margin: 0 44px 8px 0; font-size: 16px; font-weight: 700; }
#room3d h3 { margin: 12px 0 4px; font: 500 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
#room3d table { width: 100%; border-collapse: collapse; font-size: 13px; }
#room3d td, #room3d th { padding: 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); vertical-align: top; text-align: left; }
#room3d .kv th { width: 84px; font-weight: 500; color: var(--mute); }
#room3d td.id { font-weight: 600; color: var(--accent); white-space: nowrap; width: 1%; }
#room3d td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#room3d .paint div { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
#room3d .sw { width: 16px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgba(255, 255, 255, 0.35); }
#room3d .btn { display: inline-flex; margin-top: 12px; padding: 8px 12px; text-decoration: none; font-size: 13px; }
body:not(.walk) #room-chip, body:not(.walk) #room3d { display: none; }
@keyframes rc-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- paint the walls (2026-12-04): panel, swatches, the "saved on this device" note ---------- */
#paint { position: fixed; right: calc(12px + var(--sr)); bottom: calc(64px + var(--sb)); z-index: 4; width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 140px - var(--st)); overflow: auto; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7); animation: rc-in 0.2s ease-out; -webkit-user-select: none; user-select: none; }
#paint .x { position: absolute; top: 6px; right: 6px; min-height: 34px; padding: 2px 12px; font-size: 18px; line-height: 1; box-shadow: none; }
#paint h2 { margin: 0 44px 4px 0; font-size: 16px; font-weight: 700; }
#paint .hint { margin: 0 0 8px; font-size: 12.5px; line-height: 1.4; color: var(--mute); }
#paint .count { font: 500 11px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
#paint .sws { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
#paint .sw { width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 9px; border: 2px solid rgba(255, 255, 255, 0.55); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); cursor: pointer; }
#paint .sw:hover { transform: scale(1.08); }
#paint .sw.custom { background: conic-gradient(from 200deg, #c0784f, #e0b04f, #8fa382, #4f6f8c, #6b5370, #c0784f); }
#paint .row { display: flex; gap: 6px; margin-top: 6px; }
#paint .row button { flex: 1; min-height: 38px; padding: 6px 8px; font-size: 13px; }
#paint .row button.primary { background: var(--accent); color: #111; font-weight: 700; }
#paint button:disabled { opacity: 0.45; cursor: default; }
#paint .msg { min-height: 18px; margin-top: 6px; font-size: 12.5px; color: var(--accent); }
#paint .note { margin: 4px 0 0; padding: 8px 10px; border-radius: 9px; background: rgba(240, 179, 35, 0.12); border: 1px solid rgba(240, 179, 35, 0.35); font-size: 12px; line-height: 1.4; }
#paint-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--sb)); z-index: 4; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 24px); padding: 8px 10px 8px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 12px 40px -16px rgba(0, 0, 0, 0.7); }
#paint-toast button { min-height: 34px; padding: 4px 10px; font-size: 13px; }
body.touch #paint { left: calc(12px + var(--sl)); right: calc(12px + var(--sr)); width: auto; bottom: calc(10px + var(--sb)); max-height: 46vh; }
body.touch #paint .hint { display: none; }
body.touch.painting #stick { display: none; }   /* painting on a phone: look around and tap; close the panel to walk */
body.touch.painting #btn-ghost, body.painting #btn-help { display: none; }
#paint .sw.on { box-shadow: 0 0 0 2px var(--panel-solid), 0 0 0 4px var(--accent); }
#paint .custombtn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; margin: 0 0 8px; padding: 6px 12px; font-size: 14px; font-weight: 600; }
#paint .custombtn .wheel, #paint .more .hue { background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
#paint .custombtn .wheel { width: 26px; height: 26px; border-radius: 50%; flex: none; background: conic-gradient(#f44, #fd4, #4d6, #4de, #46f, #d4f, #f44); border: 2px solid rgba(255, 255, 255, 0.7); }
#paint .more .prev { display: flex; align-items: center; gap: 12px; margin: 2px 0 10px; }
#paint .more .prev .dot { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.75); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); flex: none; }
#paint .more .prev b { display: block; font-size: 15px; }
#paint .more .prev .hex { font: 500 11px var(--mono); color: var(--mute); }
#paint .more .pad { position: relative; height: 150px; border-radius: 12px; cursor: crosshair; touch-action: none; border: 1px solid rgba(255, 255, 255, 0.15); }
#paint .more .hue { position: relative; height: 16px; margin: 12px 0 4px; border-radius: 8px; cursor: pointer; touch-action: none; }
#paint .more .knob { position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); pointer-events: none; }
#paint .more .hue .knob { top: 50%; }
#paint .more .sub { margin: 12px 0 6px; font: 500 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--mute); }
#paint .more .grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }   /* 18 tones: two full rows */
#paint .more .grid .sw { width: 100%; height: auto; aspect-ratio: 1; max-width: 32px; border-radius: 50%; border-width: 1.5px; }
#paint .more .back { width: 100%; min-height: 36px; margin-top: 8px; padding: 6px 10px; font-size: 13px; background: transparent; box-shadow: none; color: var(--mute); }
#paint.more-on .hint { display: none; }
body.touch #paint .more .pad { height: 120px; }
body.touch #paint.more-on { max-height: 64vh; }
/* the custom colour: a rainbow dot at the end of the swatches (user 2026-12-04) */
#paint .sw.wheelsw { border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); background: conic-gradient(#e8505b, #f0a03c, #e2c83f, #4cbf73, #3fa7d6, #7a5cd6, #d65cb0, #e8505b); }
body.touch #paint .more .grid { grid-template-columns: repeat(auto-fill, 30px); }
body.touch #paint .more .grid .sw { width: 30px; }
