/* قرية سينا: واجهة فوگ المشهد الثلاثي الأبعاد (للموبايل أول)
   ألوان سينا: الأحمر للوحات والأزرار، والأبيض للبطاقات، والكلام بخط Alexandria */
:root {
  --red: #A62328; --deep: #7A181F; --cream: #F0E7D5; --light: #FAF6F0; --ink: #1F1A1D; --muted: #6B5F58;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --ease: cubic-bezier(.2, .7, .2, 1);
  font-family: "Alexandria", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--red); color: var(--ink); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p, figure, blockquote { margin: 0; }
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.app { position: fixed; inset: 0; overflow: hidden; background: #F3E5CB; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* البطاقات فوگ البيوت */
.labels, .dimtags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 6px 15px 8px; border: 0; border-radius: 999px;
  background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 800; line-height: 1.3; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(60, 30, 15, .22);
  pointer-events: auto; transform-origin: 50% 100%;
  transition: opacity .3s var(--ease);
  will-change: transform;
}
.tag::after {                                  /* سهم صغير يأشر على البيت */
  content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px;
  background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}
.tag i { width: 7px; height: 7px; background: var(--red); transform: rotate(45deg); flex: none; }
.tag--press { background: var(--red); color: #fff; padding-inline-start: 11px; }
.tag--press img { width: 26px; height: auto; }
.tag--plot { background: rgba(166, 35, 40, .9); color: #fff; outline: 2px dashed rgba(255, 255, 255, .85); outline-offset: -5px; }
.tag.is-hidden, .tag.is-under { opacity: 0; pointer-events: none; }

/* الراس: لسان الشعار الأبيض والعنوان */
.top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 12px; padding: 0 var(--gutter); pointer-events: none; transition: opacity .35s var(--ease), transform .35s var(--ease); }
.top__tab { pointer-events: auto; display: flex; align-items: flex-end; justify-content: center; width: 58px; height: calc(78px + var(--st)); padding-bottom: 13px; background: #fff; box-shadow: 0 6px 18px rgba(60, 30, 15, .18); }
.top__tab img { width: 40px; height: auto; display: block; }
.top__title { margin-top: calc(var(--st) + 14px); color: var(--ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .5); transition: color .6s; }
.top__title h1 { font-size: 23px; font-weight: 900; line-height: 1.25; }
.top__title p { font-size: 13.5px; font-weight: 500; color: var(--deep); }
.top__btn { pointer-events: auto; margin-top: calc(var(--st) + 14px); margin-inline-start: auto; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%; background: #fff; color: var(--red); box-shadow: 0 6px 18px rgba(60, 30, 15, .2); }
.top__btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.top__btn .i-moon { fill: currentColor; stroke: none; }
.top__btn .i-sun, .is-night .top__btn .i-moon { display: none; }
.is-night .top__btn .i-sun { display: block; }
.is-night .top__title { color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, .4); }
.is-night .top__title p { color: var(--cream); }

/* تلميح أول مرة */
.hint {
  position: absolute; left: 50%; bottom: calc(86px + var(--sb)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 9px 16px 11px; border-radius: 999px;
  background: rgba(31, 26, 29, .72); color: #fff; font-size: 13.5px; font-weight: 600; text-align: center;
  pointer-events: none; transition: opacity .5s var(--ease); white-space: nowrap;
}
.hint.is-gone { opacity: 0; }

/* قائمة البيوت تحت */
.dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  padding: 26px var(--gutter) calc(14px + var(--sb));
  background: linear-gradient(to top, rgba(60, 30, 15, .32), transparent);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.dock::-webkit-scrollbar { display: none; }
.chip { flex: none; scroll-snap-align: start; min-height: 44px; padding: 8px 18px 10px; border: 0; border-radius: 999px; background: #fff; color: var(--ink); font-size: 15px; font-weight: 800; box-shadow: 0 6px 16px rgba(60, 30, 15, .18); }
.chip--press { background: var(--red); color: #fff; }
.chip--plot { background: rgba(166, 35, 40, .9); color: #fff; outline: 2px dashed rgba(255, 255, 255, .85); outline-offset: -5px; }
.has-focus .dock, .has-focus .hint, .in-room .dock, .in-room .hint, .in-room .top, .in-room .labels { opacity: 0; pointer-events: none; }
.has-focus .dock { transform: translateY(30px); }

/* لوحة البيت المختار (أحمر سينا بنقشة الزولية) */
.sheet, .room__panel { background: var(--red); color: #fff; isolation: isolate; }
.sheet::before, .room__panel::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--deep); opacity: .42;
  -webkit-mask: url("../assets/pattern/sina-zoulia-mono-tile.svg") repeat 0 0 / 300px 135px;
          mask: url("../assets/pattern/sina-zoulia-mono-tile.svg") repeat 0 0 / 300px 135px;
}
.sheet {
  position: absolute; left: 12px; right: 12px; bottom: calc(12px + var(--sb));
  padding: 20px 20px 18px; border-radius: 24px;
  box-shadow: 0 18px 50px rgba(60, 20, 15, .35);
  transform: translateY(calc(100% + 40px)); transition: transform .5s var(--ease);
}
.sheet.is-open { transform: none; }
.sheet__label { display: inline-flex; align-items: center; gap: 8px; padding: 3px 13px 5px; border: 2px solid #fff; border-radius: 999px; font-size: 13px; font-weight: 800; }
.sheet__label::before { content: ""; width: 7px; height: 7px; background: #fff; transform: rotate(45deg); }
.sheet h2 { margin-top: 10px; font-size: 30px; font-weight: 900; line-height: 1.25; }
.sheet p:not(.sheet__label) { margin-top: 6px; color: rgba(255, 255, 255, .9); font-size: 15px; line-height: 1.65; }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sheet__close { position: absolute; top: 14px; inset-inline-end: 14px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.sheet__close::before, .sheet__close::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 2px; background: #fff; transform: translate(-50%, -50%) rotate(45deg); }
.sheet__close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 22px 10px; border-radius: 999px; font-size: 15.5px; font-weight: 800; text-decoration: none; border: 2px solid #fff; }
.btn--solid { background: #fff; color: var(--red); }
.btn--line { background: transparent; color: #fff; }
.btn--block { display: flex; width: 100%; margin-top: 14px; }

/* الانتقال للبيت */
.fade { position: absolute; inset: 0; background: #F1E6D3; opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); }
.fade.is-on { opacity: 1; }

/* جوّه البيت */
.room { position: absolute; inset: 0; pointer-events: none; display: none; }
.room.is-open { display: block; }
.room__top {
  pointer-events: auto; position: absolute; top: 0; left: 0; right: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  padding: calc(var(--st) + 12px) var(--gutter) 22px;
  background: linear-gradient(to bottom, rgba(40, 24, 18, .7), transparent); color: #fff;
}
.room__top h2 { font-size: 20px; font-weight: 900; }
.room__back { display: inline-flex; align-items: center; gap: 4px; min-height: 42px; padding: 6px 12px 8px 16px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .18); color: #fff; font-size: 14px; font-weight: 800; }
.room__back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.room__tabs { flex-basis: 100%; display: flex; gap: 8px; }
.room__tabs button { min-height: 40px; padding: 6px 16px 8px; border: 2px solid #fff; border-radius: 999px; background: transparent; color: #fff; font-size: 14px; font-weight: 800; }
.room__tabs [aria-selected="true"] { background: #fff; color: var(--red); }
.room__panel {
  pointer-events: auto; position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 50%; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px var(--gutter) calc(16px + var(--sb)); border-radius: 26px 26px 0 0;
  box-shadow: 0 -12px 40px rgba(40, 20, 15, .35);
}
.room__panel h3 { font-size: 22px; font-weight: 900; line-height: 1.3; }
.room__details { margin-top: 2px; color: rgba(255, 255, 255, .88); font-size: 14px; }
.dims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.dim { display: grid; justify-items: center; gap: 2px; padding: 10px 4px 11px; border: 0; border-radius: 16px; background: #fff; color: var(--ink); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.dim svg { width: 40px; height: 44px; overflow: visible; }
.dim .ic { fill: none; stroke: #8C807A; stroke-width: 1.3; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.dim .edge { fill: none; stroke: var(--red); stroke-width: 2.8; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.dim__l { font-size: 12px; font-weight: 600; color: var(--muted); }
.dim__v { font-size: 12.5px; color: var(--muted); }
.dim__v b { font-size: 22px; font-weight: 900; color: var(--red); }
.dim.is-on { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--ink); }
.review { position: relative; margin-top: 14px; padding: 16px 16px 14px; border-radius: 18px; background: #fff; color: var(--ink); }
.review blockquote { font-size: 15.5px; font-weight: 600; line-height: 1.7; }
.review figcaption { margin-top: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.review figcaption::before { content: "— "; }
.review--draft { outline: 2px dashed var(--red); outline-offset: -6px; }
.review__draft { display: inline-block; margin-bottom: 6px; padding: 2px 10px 4px; border-radius: 999px; background: var(--cream); color: var(--red); font-size: 12px; font-weight: 800; }
.room__hint { margin-top: 10px; color: rgba(255, 255, 255, .8); font-size: 12.5px; text-align: center; }
.dimtags { opacity: 0; transition: opacity .3s var(--ease); }
.dimtags.is-on { opacity: 1; }
.dimtag { position: absolute; left: 0; top: 0; padding: 3px 9px 5px; border-radius: 999px; background: #fff; color: var(--ink); font-size: 12.5px; font-weight: 800; white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); }
.dimtag.is-on { background: var(--red); color: #fff; }

/* التحميل */
.loader { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--red); color: #fff; isolation: isolate; transition: opacity .6s var(--ease), visibility 0s .6s; }
.loader::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--deep); opacity: .42; -webkit-mask: url("../assets/pattern/sina-zoulia-mono-tile.svg") repeat 0 0 / 300px 135px; mask: url("../assets/pattern/sina-zoulia-mono-tile.svg") repeat 0 0 / 300px 135px; }
.loader__logo img { width: 92px; display: block; transform: translate(3.5%, -2.5%); }   /* الشعار وحده بالنص: يزحف يمين وفوگ للعين */
.loader p { font-size: 22px; font-weight: 900; }
.loader__track { width: 140px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.loader__track span { display: block; height: 100%; background: #fff; transform: scaleX(0); transform-origin: right; transition: transform .3s var(--ease); }
.loader.is-done { opacity: 0; visibility: hidden; }

/* بدون WebGL */
.nogl { display: none; position: absolute; inset: 0; z-index: 20; overflow-y: auto; padding: calc(var(--st) + 40px) var(--gutter) 40px; background: var(--red); color: #fff; text-align: center; }
.no-webgl .nogl { display: block; }
.nogl h2 { margin-top: 12px; font-size: 28px; font-weight: 900; }
.nogl p { margin: 8px auto 20px; max-width: 30em; line-height: 1.7; }
.nogl ul { list-style: none; margin: 0 auto 24px; padding: 0; max-width: 26em; text-align: start; }
.nogl li { padding: 12px 16px; margin-bottom: 8px; border-radius: 14px; background: #fff; color: var(--ink); }
.nogl li b { display: block; font-size: 17px; }
.nogl li span { display: block; margin-top: 6px; font-weight: 700; }
.nogl li small { display: block; font-size: 14px; color: var(--muted); }

@media (min-width: 760px) {
  .sheet { left: auto; right: 24px; width: 380px; bottom: 24px; }
  .room__panel { left: auto; right: 24px; bottom: 24px; width: 400px; max-height: calc(100% - 140px); border-radius: 26px; }
  .top__title h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
