/* Khaneh for Rowzan: warm lime-wash paper, umber ink, Instrument Sans, one ease. */
@font-face { font-family: Brand; src: url(../assets/fonts/Brand-400.woff2) format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: Brand; src: url(../assets/fonts/Brand-400i.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: Brand; src: url(../assets/fonts/Brand-500.woff2) format("woff2"); font-weight: 500; font-display: block; }
@font-face { font-family: Brand; src: url(../assets/fonts/Brand-700.woff2) format("woff2"); font-weight: 700; font-display: block; }
@font-face { font-family: Nastaliq; src: url(../assets/fonts/Nastaliq.woff2); font-display: block; }
@font-face { font-family: Vazir; src: url(../assets/fonts/Vazir-400.woff2); font-weight: 400; }

:root {
  --ink: #1c1a17; --paper: #f3eee5; --muted: #7d7468; --rule: #d6cdbf; --soft: #ebe4d8;
  --ease: cubic-bezier(.5, 0, 0, 1);
  --top: 76px; --bottom: 54px; --side: 24px; --panel: 384px;
  font-family: Brand, "Helvetica Neue", Arial, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- frame ---------- */
.bar { position: fixed; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--side); z-index: 20; background: var(--paper); }
.bar.top { top: 0; height: var(--top); }
.bar.bottom { bottom: 0; height: var(--bottom); font-size: 13px; color: var(--muted); }
.logo img { display: block; height: 40px; width: auto; }
.ident { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: baseline; gap: 10px; font-size: 14px; white-space: nowrap; }
.ident .k { font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.ident .fa { font-family: Nastaliq, Vazir, serif; font-size: 22px; color: var(--muted); line-height: 0; position: relative; top: 3px; }
.ident .sub { color: var(--muted); }
.modes { display: flex; gap: 30px; text-transform: uppercase; font-weight: 500; font-size: 15px; letter-spacing: .02em; }
.modes button { color: var(--muted); transition: color .15s; padding: 10px 0; position: relative; }
.modes button:hover, .modes button.on { color: var(--ink); }
.modes button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: 4px; height: 1px; background: var(--ink); }
.bottom .right { display: flex; gap: 26px; }
.bottom button { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: 12px; font-weight: 500; }
.bottom button:hover, .bottom button[aria-pressed="true"] { color: var(--ink); }
#foot-place { color: var(--ink); }
#foot-place em { color: var(--muted); font-style: normal; }

.stage { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.stage { position: fixed; top: var(--top); bottom: var(--bottom); left: var(--side); right: var(--side); overflow: hidden; background: #e9e8e5; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#gl.drag { cursor: grabbing; }
#gl.art { cursor: zoom-in; }
#gl.walk { cursor: pointer; }

/* ---------- overlays inside the stage ---------- */
.place { position: absolute; left: 14px; top: 14px; background: var(--paper); padding: 8px 12px 7px; font-size: 12.5px; line-height: 1.4; pointer-events: none; transition: opacity .6s var(--ease); max-width: calc(100% - 28px); }
.place b { display: block; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.place span { color: var(--muted); }
.tip { position: absolute; z-index: 6; pointer-events: none; background: var(--paper); padding: 7px 10px 6px; font-size: 12.5px; line-height: 1.35; opacity: 0; transform: translate(14px, 14px); transition: opacity .2s; white-space: nowrap; }
.tip.on { opacity: 1; }
.tip b { font-weight: 500; display: block; }
.tip i { color: var(--muted); }
.hint { position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 10px); background: var(--paper); padding: 10px 16px 9px; font-size: 13px; opacity: 0; transition: opacity .8s var(--ease), transform .8s var(--ease); pointer-events: none; white-space: nowrap; }
.hint.on { opacity: 1; transform: translate(-50%, 0); }
.hint kbd { font: inherit; font-weight: 500; }
.toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-size: 13px; padding: 8px 14px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.on { opacity: 1; }

.floors { position: absolute; left: 18px; top: 58px; display: flex; gap: 0; background: var(--paper); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.floors button { padding: 8px 12px; color: var(--muted); }
.floors button.on { color: var(--ink); box-shadow: inset 0 -1px 0 var(--ink); }

.mini { position: absolute; left: 14px; bottom: 14px; background: var(--paper); padding: 8px; cursor: pointer; transition: opacity .5s var(--ease), transform .5s var(--ease); }
.mini canvas { display: block; }
.mini #miniDot { position: absolute; left: 8px; top: 8px; }
.mini.off { opacity: 0; transform: translateY(8px); pointer-events: none; }

#markers { position: absolute; inset: 0; pointer-events: none; }
.mk { position: absolute; width: 0; height: 0; pointer-events: auto; cursor: pointer; font-size: 11px; font-weight: 500; white-space: nowrap; }
.mk i { position: absolute; left: -9px; top: -9px; display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); color: var(--paper); font-style: normal; font-size: 10px; line-height: 18px; text-align: center; transition: transform .2s var(--ease); }
.mk:hover i { transform: scale(1.25); }
.mk span { position: absolute; left: 14px; top: -10px; background: var(--paper); padding: 2px 5px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.mk:hover span { opacity: 1; }
.rl { position: absolute; transform: translate(-50%, -50%); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 500; color: var(--ink); background: rgba(255,255,255,.86); padding: 3px 6px 2px; white-space: nowrap; pointer-events: none; }

/* ---------- artwork / tour panel ---------- */
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: var(--panel); background: var(--paper); padding: 26px 30px 24px; display: flex; flex-direction: column; transform: translateX(101%); transition: transform .7s var(--ease); z-index: 8; overflow-y: auto; }
.panel.on { transform: none; }
.panel .close { position: absolute; top: 22px; right: 26px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; color: var(--muted); }
.panel .close:hover { color: var(--ink); }
.panel .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; color: var(--muted); padding-right: 60px; line-height: 1.5; min-height: 18px; }
.panel .body { margin-top: 38px; flex: 1; }
.panel h2 { font-size: 28px; line-height: 1.15; font-weight: 700; margin: 0 0 14px; letter-spacing: -.005em; }
.panel h3 { font-size: 16px; font-weight: 500; margin: 0 0 4px; }
.panel p { margin: 0; font-size: 15.5px; line-height: 1.6; }
.panel p + p { margin-top: 0; }
.panel .cap p { line-height: 1.55; }
.panel .cap em { font-style: italic; }
.panel .text { margin-top: 18px; color: #222; font-size: 15px; line-height: 1.65; }
.panel .text p + p { margin-top: .8em; }
.panel .scale { margin-top: 26px; display: flex; align-items: flex-end; gap: 14px; color: var(--muted); font-size: 12px; }
.panel .scale svg { display: block; }
.panel .actions { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 22px 0 18px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.panel .actions a, .panel .actions button { text-decoration: none; border-bottom: 1px solid var(--ink); padding-bottom: 2px; }
.panel .actions a:hover, .panel .actions button:hover { color: var(--muted); border-color: var(--muted); }
.panel .pager { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--rule); padding-top: 16px; font-size: 13px; }
.panel .pager button { font-weight: 500; }
.panel .pager button:hover { color: var(--muted); }
.panel .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.panel .autoplay { display: none; align-items: center; gap: 14px; margin-top: 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.panel.tour .autoplay { display: flex; }
.panel .autoplay .bar { position: relative; flex: 1; height: 1px; background: var(--rule); display: block; }
.panel .autoplay .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ink); display: block; }

/* ---------- index ---------- */
.index { position: absolute; inset: 0; z-index: 9; background: var(--paper); overflow-y: auto; padding: 34px 40px 60px; animation: fade .5s var(--ease); }
.index .close { position: absolute; top: 26px; right: 32px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; color: var(--muted); }
.index .cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; max-width: 1240px; }
.index h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; color: var(--muted); margin: 0 0 6px; }
.index h2 { font-size: 25px; line-height: 1.25; margin: 0 0 22px; font-weight: 700; }
.index ul { list-style: none; padding: 0; margin: 0; }
.index li button { display: grid; grid-template-columns: 54px 1fr; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 9px 0; border-top: 1px solid #eee; }
.index li button:hover { color: var(--muted); }
.index li img { width: 54px; height: 54px; object-fit: contain; background: var(--soft); }
.index li .t { font-size: 13.5px; line-height: 1.4; }
.index li .t b { font-weight: 500; display: block; }
.index li .t i { color: var(--muted); }
.index .places button { grid-template-columns: 1fr; padding: 11px 0; font-size: 15px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: var(--paper); display: flex; flex-direction: column; animation: fade .4s var(--ease); }
.lightbox .frame { flex: 1; position: relative; overflow: hidden; margin: 70px 40px 10px; cursor: zoom-in; }
.lightbox .frame.zoom { cursor: zoom-out; }
.lightbox img { position: absolute; left: 50%; top: 50%; max-width: 100%; max-height: 100%; transform: translate(-50%, -50%); transition: transform .5s var(--ease); }
.lightbox .cap { text-align: center; font-size: 13px; padding: 10px 20px 26px; line-height: 1.5; }
.lightbox .cap em { font-style: italic; }
.lightbox .close { position: absolute; top: 26px; right: 32px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; color: var(--muted); z-index: 2; }

/* ---------- intro ---------- */
.intro { position: fixed; inset: 0; z-index: 40; background: var(--paper); display: flex; flex-direction: column; padding: 18px var(--side) 22px; transition: opacity 1.2s var(--ease), visibility 0s linear 1.2s; }
.intro.gone { opacity: 0; visibility: hidden; }
.intro-top img { height: 40px; display: block; margin-top: 18px; }
.intro-grid { flex: 1; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; align-items: center; min-height: 0; }
.intro .kicker { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; font-weight: 500; color: var(--muted); }
.intro h1 { margin: 18px 0 8px; display: flex; align-items: baseline; gap: 26px; font-weight: 700; font-size: clamp(64px, 9vw, 132px); line-height: .95; letter-spacing: -.025em; }
.intro h1 .fa { font-family: Nastaliq, Vazir, serif; font-weight: 400; font-size: .78em; color: var(--muted); letter-spacing: 0; }
.intro .lead { font-size: clamp(19px, 1.7vw, 25px); line-height: 1.38; max-width: 30em; margin: 10px 0 34px; }
.intro .now { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; max-width: 560px; font-size: 14.5px; line-height: 1.5; border-top: 1px solid var(--ink); padding-top: 14px; }
.intro .now div { display: flex; flex-direction: column; }
.intro .now .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.intro .now b { font-weight: 500; }
.intro .now span:last-child { color: var(--muted); }
.intro .enter { margin-top: 42px; max-width: 560px; }
.intro .enter button { display: flex; width: 100%; justify-content: space-between; align-items: baseline; font-size: clamp(22px, 2vw, 28px); font-weight: 500; padding: 4px 0 14px; color: var(--muted); transition: color .3s; }
.intro .enter button:not(:disabled) { color: var(--ink); }
.intro .enter button:not(:disabled):hover .t { transform: translateX(8px); }
.intro .enter .t { transition: transform .5s var(--ease); }
.intro .enter .pct { font-variant-numeric: tabular-nums; font-size: .7em; }
.intro .enter .line { display: block; height: 1px; background: var(--rule); position: relative; }
.intro .enter .line i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ink); display: block; transition: width .4s var(--ease); }
.intro .how { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.intro-plan { height: 100%; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.intro-plan canvas { max-width: 100%; max-height: calc(100% - 30px); }
.intro-plan .plan-cap { font-size: 12px; color: var(--muted); margin-top: 12px; }
.intro-foot { font-size: 12px; color: var(--muted); }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; background: var(--paper); z-index: 99; }

/* ---------- joystick + help ---------- */
.joy { position: absolute; left: 22px; bottom: 26px; width: 112px; height: 112px; border-radius: 50%; background: rgba(255,255,255,.28); box-shadow: inset 0 0 0 1px rgba(255,255,255,.75); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); touch-action: none; z-index: 5; transition: opacity .4s var(--ease); }
.joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: var(--paper); box-shadow: 0 2px 10px rgba(0,0,0,.18); display: block; }
.joy.dim { opacity: 0; pointer-events: none; }
.help-btn { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 50%; background: var(--paper); font-weight: 500; font-size: 14px; z-index: 6; display: none; }
.help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 9; background: var(--paper); padding: 26px 30px 24px; width: min(640px, calc(100% - 32px)); animation: fade .4s var(--ease); }
.help h4 { margin: 0 0 16px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; color: var(--muted); }
.help .close { position: absolute; top: 22px; right: 26px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; color: var(--muted); }
.help dl { display: grid; grid-template-columns: 120px 1fr; gap: 9px 16px; margin: 0; font-size: 14px; line-height: 1.4; }
.help dt { font-weight: 500; }
.help dd { margin: 0; color: #333; }
.help .touch { display: none; }
body.touch .help .touch { display: grid; } body.touch .help .desk { display: none; }
body.touch .help-btn { display: block; }
.fs-btn { position: absolute; right: 54px; top: 14px; width: 32px; height: 32px; border-radius: 50%; background: var(--paper); z-index: 6; display: none; place-items: center; }
body.touch .fs-btn { display: grid; }
.fs-btn .out, body.immersive .fs-btn .in { display: none; }
body.immersive .fs-btn .out { display: inline; }
/* immersive: the stage takes the whole screen; the modes float as a small pill */
body.immersive { --top: 0px; --bottom: 0px; --side: 0px; }
body.immersive .bar.top { background: transparent; height: auto; padding: 10px 0 0; justify-content: center; pointer-events: none; top: env(safe-area-inset-top); }
body.immersive .bar.top .logo, body.immersive .bar.top .ident { display: none; }
body.immersive .modes { pointer-events: auto; background: var(--paper); padding: 0 16px; gap: 16px; }
body.immersive .modes button { padding: 8px 0; }
body.immersive .modes button.on::after { bottom: 3px; }
body.immersive .place { top: calc(56px + env(safe-area-inset-top)); }
body.immersive .help-btn, body.immersive .fs-btn { top: calc(56px + env(safe-area-inset-top)); }
body.immersive .bar.bottom { display: none; }
body.immersive .stage { bottom: 0; }
body.touch .hint { bottom: 150px; }

/* ---------- small screens ---------- */
@media (max-width: 860px), (max-height: 520px) {
  :root { --top: 58px; --bottom: 0px; --side: 0px; }
  .logo img { height: 28px; }
  .ident { display: none; }
  .bar.top { padding: 0 16px; }
  .modes { gap: 18px; font-size: 13px; }
  .bar.bottom { display: none; }
  .mini { display: none; }
  .panel { top: auto; left: 0; right: 0; width: auto; max-height: 50%; transform: translateY(101%); padding: 20px 20px calc(16px + env(safe-area-inset-bottom)); }
  .stage { bottom: env(safe-area-inset-bottom); }
  .place { font-size: 11.5px; padding: 6px 10px 5px; }
  .place span { display: block; max-width: 62vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .floors { top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); box-shadow: 0 1px 0 #eee; }
  .help dl { grid-template-columns: 96px 1fr; font-size: 13px; }
  .panel .body { margin-top: 18px; }
  .panel h2 { font-size: 22px; }
  .panel .text { font-size: 14px; }
  .panel .actions { margin: 14px 0 12px; }
  .place { top: 12px; left: 14px; }
  .hint { bottom: 16px; font-size: 12px; white-space: normal; width: max-content; max-width: calc(100% - 32px); text-align: center; }
  .index { padding: 24px 18px 40px; }
  .index .cols { grid-template-columns: 1fr; gap: 26px; }
  .intro { padding: 12px 18px 16px; overflow-y: auto; }
  .intro-top img { height: 30px; margin-top: 6px; }
  .intro-grid { grid-template-columns: 1fr; gap: 10px; align-items: start; padding-top: 22px; }
  .intro-plan { display: none; }
  .intro h1 { gap: 16px; margin-top: 12px; }
  .intro .now { grid-template-columns: 1fr 1fr; gap: 16px; font-size: 13.5px; }
  .intro .enter { margin-top: 30px; }
  .lightbox .frame { margin: 60px 12px 6px; }
}

/* phones held sideways: a slim header, the card becomes a side sheet */
@media (max-height: 520px) and (min-width: 600px) {
  :root { --top: 46px; }
  .logo img { height: 24px; }
  .panel { top: 0; bottom: 0; left: auto; width: min(340px, 46%); max-height: none; transform: translateX(101%); }
  .panel .body { margin-top: 14px; }
  .panel .scale { display: none; }
  .joy { width: 96px; height: 96px; left: 16px; bottom: 16px; }
}
