/* Living room (home page) */
:root { --mono: "JetBrains Mono", ui-monospace, monospace; --teal: #13a18e; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3f6f6c; font-family: var(--mono); }
body.night { background: #12262b; }

/* The room is a fixed 1440×900 canvas, scaled to fill the screen.
   On narrow/tall screens it fills the height and you can swipe sideways. */
.viewport { position: fixed; inset: 0; overflow: hidden; }
/* Blurred copy of the room behind the zoomed-out stage, so the edges never show empty bars */
.viewport::before {
  content: ""; position: fixed; inset: -40px; z-index: -1;
  background: url("../assets/img/room/bg-day.jpg") center / cover;
  filter: blur(18px) brightness(.85);
}
body.night .viewport::before { background-image: url("../assets/img/room/bg-night.jpg"); }
.stage { box-shadow: 0 0 60px rgba(0,0,0,.25); overflow: hidden; } /* keep items like the lamp inside the room's edge */
.viewport.pan { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.viewport.pan::-webkit-scrollbar { display: none; }
.stage { position: absolute; left: 0; top: 0; width: 1440px; height: 900px; transform-origin: 0 0; }

.layer, .item, .hotspot, .bubble, .water-btn, .tag, .drops { position: absolute; }
.layer, .item img { display: block; width: 100%; height: auto; }
.layer { pointer-events: none; }
.bg { left: 0; top: 0; width: 1440px; height: 900px; object-fit: cover; }
img { user-select: none; -webkit-user-drag: none; }

button.item, button.hotspot { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.item { transition: transform .35s cubic-bezier(.3,1.6,.5,1), filter .35s; }
.item.link:hover, .item.link:focus-visible, .lamp:hover, .phone:hover { transform: translateY(-6px) scale(1.015); filter: drop-shadow(0 12px 14px rgba(0,0,0,.18)); }
.item:focus-visible, .hotspot:focus-visible, .water-btn:focus-visible { outline: 3px solid #fff; outline-offset: 4px; border-radius: 12px; }

/* labels */
/* Frosted-glass look shared by labels and speech bubbles */
.tag, .bubble {
  background: linear-gradient(135deg, rgba(255,255,255,.28) 0%, rgba(255,255,255,.04) 100%), rgba(18, 112, 108, .55);
  -webkit-backdrop-filter: blur(10px) saturate(1.5); backdrop-filter: blur(10px) saturate(1.5);
  border: 1px solid rgba(255,255,255,.5);
  box-shadow: 0 6px 18px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.55);
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
body.night .tag, body.night .bubble { background: linear-gradient(135deg, rgba(255,255,255,.18) 0%, rgba(255,255,255,.04) 100%), rgba(16, 40, 48, .4); border-color: rgba(255,255,255,.3); }
.tag {
  text-decoration: none; white-space: nowrap;
  font-size: 13px; padding: 4px 10px; border-radius: 8px; letter-spacing: .02em;
  transition: transform .3s;
}
.item.link .tag { opacity: .95; }
.item.link:hover .tag { transform: translateY(-4px) rotate(-3deg); }
.tv-tag { font-size: 11px; line-height: 1.3; white-space: normal; transform: rotate(0); }
.tv-tag:hover { transform: rotate(-3deg) scale(1.05); }

/* TV: grows slightly from its base on hover, so it stays standing on the sideboard */
.tv { transform-origin: 50% 96%; }
.item.link.tv:hover, .item.link.tv:focus-visible { transform: scale(1.025); filter: drop-shadow(0 6px 8px rgba(0,0,0,.15)); }
/* Switched off: the whole painted off-TV (tv-off-2.png) replaces the on-TV
   (tv-on.png, aligned to it). */
.tv .tv-on, .tv .tv-off-img { transition: none; }
.tv .tv-off-img { position: absolute; left: 0; top: 0; opacity: 0; }
body.tv-off .tv .tv-off-img { opacity: 1; }
body.tv-off .tv .tv-on { opacity: 0; }

/* The switch-off animation is clipped to the exact shape of the glass
   (tv-screen-mask-2.png, same 540×636 frame; glass box x 44–311, y 325–576). */
.tv .screen { position: absolute; inset: 0; pointer-events: none;
  -webkit-mask: url("../assets/img/room/tv-screen-mask-2.png") 0 0 / 100% 100% no-repeat;
          mask: url("../assets/img/room/tv-screen-mask-2.png") 0 0 / 100% 100% no-repeat; }
.tv .crt { position: absolute; left: 8.15%; top: 51.1%; width: 49.63%; height: 39.62%; }

/* Old-CRT switch-off: a copy of the picture flares, collapses to a bright
   line, then to a dot (and the reverse when switching on). */
.tv .crt { overflow: hidden; visibility: hidden; }
.tv .crt img { position: absolute; left: -16.42%; top: -128.97%; width: 201.49%; max-width: none; transition: none; }
.tv .crt::after { content: ""; position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, #fff 0%, #eafcff 55%, #bfe9f5 100%); }
.tv .crt.off, .tv .crt.on { visibility: visible; }
.tv .crt.off { animation: crt-off .6s cubic-bezier(.6,0,.4,1) forwards; }
.tv .crt.off::after { animation: crt-flash .6s linear forwards; }
.tv .crt.on { animation: crt-off .5s cubic-bezier(.6,0,.4,1) reverse forwards; }
.tv .crt.on::after { animation: crt-flash .5s linear reverse forwards; }
@keyframes crt-off {
  0%   { transform: scale(1, 1); opacity: 1; }
  45%  { transform: scale(1, .012); opacity: 1; }
  80%  { transform: scale(.04, .012); opacity: 1; }
  100% { transform: scale(0, 0); opacity: 0; }
}
@keyframes crt-flash {
  0%   { opacity: 0; }
  30%  { opacity: .85; }
  45%, 100% { opacity: 1; }
}

/* Sideboard snacks: doors fade on hover to reveal snacks */
.snacks-wrap .snacks { position: absolute; opacity: 0; transform: translateY(8px) scale(.96); transition: .4s cubic-bezier(.3,1.5,.5,1); z-index: 2; pointer-events: none; }
.snacks-wrap .sideboard { position: relative; width: 100%; }
.snacks-wrap:hover .snacks, .snacks-wrap.open .snacks { opacity: 1; transform: none; }
.snacks-wrap { cursor: pointer; }

/* Pop-up bubbles (snack cabinet, figurine) */
.pop-bubble { opacity: 0; transform: translateY(6px) scale(.96); pointer-events: none; z-index: 5; }
.pop-bubble.show, .snacks-wrap:hover + .stash-bubble { opacity: 1; transform: none; }
.figure-bubble { min-width: 0; font-size: 13px; font-style: italic; padding: 7px 12px; }
.figure { transform-origin: 50% 100%; animation: glow 2.6s ease-in-out infinite; }
.figure:hover { animation: none; filter: drop-shadow(0 0 4px #fff6c8) drop-shadow(0 0 12px rgba(255, 214, 80, 1)) drop-shadow(0 0 26px rgba(255, 190, 40, .9)); }
@keyframes glow { /* pulsing golden glow so visitors know he's clickable */
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 240, 170, .7)) drop-shadow(0 0 8px rgba(255, 210, 80, .35)); }
  50%      { filter: drop-shadow(0 0 4px #fff6c8) drop-shadow(0 0 12px rgba(255, 214, 80, 1)) drop-shadow(0 0 22px rgba(255, 190, 40, .75)); }
}
.figure.wiggle { animation: wob .7s ease-in-out, glow 2.6s ease-in-out infinite; }
@keyframes wob { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

/* Plant */
.plant { transform-origin: 50% 100%; transition: transform .6s; }
.plant.happy { animation: sway 1.4s ease-in-out 2; }
@keyframes sway { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-3deg) scale(1.03); } 75% { transform: rotate(3deg) scale(1.03); } }
.bubble {
  font-size: 11px; line-height: 1.35; white-space: pre-line;
  padding: 7px 10px; border-radius: 10px; min-width: 80px;
  transition: opacity .3s, transform .3s;
}
.water-btn {
  background: #fff; border: 0; border-radius: 6px; padding: 3px 9px; font: 12px var(--mono); cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); transition: transform .2s;
}
.water-btn:hover { transform: scale(1.08) rotate(-3deg); }
.drops span { position: absolute; width: 7px; height: 10px; background: #6cc6ff; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; animation: drop .9s ease-in forwards; }
@keyframes drop { from { transform: translateY(-30px); opacity: 1; } to { transform: translateY(60px); opacity: 0; } }

/* Phone */
.phone.ringing { animation: ring .12s linear 8; }
@keyframes ring { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.phone-bubble { opacity: 0; transform: translateY(6px); pointer-events: none; }
.phone-bubble.show { opacity: 1; transform: none; pointer-events: auto; }
.phone-bubble a { color: #fff; }

/* Record player */
.record .pill {
  position: absolute; left: 44px; top: 18px; background: #fff; border-radius: 6px; padding: 4px 10px;
  font: 12px var(--mono); color: #333; box-shadow: 0 2px 8px rgba(0,0,0,.18); white-space: nowrap; transition: transform .2s;
}
.record:hover .pill { transform: scale(1.06); }
body.playing .record .ico { display: inline-block; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }


/* Framed certificate on the wall */
.cert { transform: rotate(-2deg); transform-origin: 50% 0; }
.cert::before { /* the nail + string */
  content: ""; position: absolute; left: 50%; top: -26px; width: 52px; height: 28px; transform: translateX(-50%);
  background: linear-gradient(to bottom right, transparent calc(50% - 1px), #4a3a2a 50%, transparent calc(50% + 1px)) left / 50% 100% no-repeat,
              linear-gradient(to bottom left,  transparent calc(50% - 1px), #4a3a2a 50%, transparent calc(50% + 1px)) right / 50% 100% no-repeat;
}
.cert::after { content: ""; position: absolute; left: 50%; top: -30px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: #3b2f25; }
.cert-frame {
  display: block; padding: 7px; background: #6b4423;
  background-image: linear-gradient(135deg, #8a5a30 0%, #5c3a1d 50%, #7a4e28 100%);
  border-radius: 3px; box-shadow: 0 10px 18px rgba(0,0,0,.28), inset 0 0 0 1px rgba(0,0,0,.35);
}
.cert-frame img { display: block; width: 100%; height: auto; border: 5px solid #f6f1e6; box-shadow: inset 0 0 6px rgba(0,0,0,.25); }
.cert:hover, .cert:focus-visible { transform: rotate(0deg) scale(1.06); filter: drop-shadow(0 12px 14px rgba(0,0,0,.2)); }
/* small label that appears only while hovering the frame */
.cert-tag {
  font-size: 9px; padding: 3px 8px; border-radius: 5px; pointer-events: none;
  opacity: 0; transform: translateX(-50%) translateY(-4px); transition: opacity .2s, transform .2s;
}
.cert:hover + .cert-tag { opacity: 1; transform: translateX(-50%); }
body.night .cert-frame { filter: brightness(.6) saturate(.8); }

/* Certificate lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(10, 20, 22, .72); backdrop-filter: blur(4px); opacity: 0; transition: opacity .25s;
}
.lightbox.show { opacity: 1; }
.lightbox[hidden] { display: none; }
.lightbox-inner { position: relative; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lightbox-inner img { max-width: min(92vw, 640px); max-height: calc(100vh - 110px); width: auto; height: auto; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.45); background: #fff; }
.lightbox-close {
  position: absolute; top: -14px; right: -14px; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: #fff; color: #1c1c1c; font-size: 16px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.lightbox-link { color: #fff; font: 600 13px var(--mono); text-decoration: underline; text-underline-offset: 4px; }

/* Night */
.night-only { opacity: 0; transition: opacity .8s; }
body.night .night-only { opacity: 1; }
.glow { mix-blend-mode: screen; }
.layer, .item img { transition: opacity .5s; }

/* Fixed UI */
.intro {
  position: fixed; left: calc(var(--room-left, 0px) + clamp(12px, 2.5vw, 36px)); top: calc(var(--room-top, 0px) + clamp(12px, 2.5vw, 22px)); z-index: 10;
  /* ends before the day/night switch in the middle */
  width: min(560px, calc(var(--room-w, 100vw) - 24px), calc(50vw - 60px - var(--room-left, 0px) - clamp(12px, 2.5vw, 36px))); min-height: 150px; padding: 18px 22px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(19,161,142,.96) 0%, rgba(19,161,142,.9) 60%, rgba(19,161,142,.55) 85%, rgba(19,161,142,0) 100%);
  color: #fff; pointer-events: none;
}
body.night .intro { background: linear-gradient(180deg, rgba(20,40,48,.92) 0%, rgba(20,40,48,.85) 60%, rgba(20,40,48,.5) 85%, rgba(20,40,48,0) 100%); }
.intro p { margin: 0; font-size: clamp(11px, 1vw, 15px); line-height: 1.6; white-space: pre-line; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.intro p::after { content: "▍"; animation: blink 1s steps(1) infinite; opacity: .8; }
.intro.done p::after { display: none; }
@keyframes blink { 50% { opacity: 0; } }

.toggle {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%); z-index: 12;
  width: 82px; height: 41px; border-radius: 999px; border: 0; background: rgba(255,255,255,.92); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
.toggle .knob {
  position: absolute; top: 4px; left: 45px; width: 33px; height: 33px; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px; background: #fde68a; transition: left .4s cubic-bezier(.3,1.5,.5,1), background .4s;
}
body.night .toggle .knob { left: 4px; background: #fbd38d; }

/* "My CV" button + menu, top-right inside the room's border */
.room-cv {
  position: fixed; z-index: 12;
  top: calc(var(--room-top, 0px) + 26px);
  right: calc(100vw - var(--room-left, 0px) - var(--room-w, 100vw) + 22px);
}
.cv-btn {
  display: inline-block; background: #ffd640; color: #1c1c1c; text-decoration: none;
  font: 600 13px var(--mono); text-transform: uppercase; letter-spacing: .02em;
  padding: 8px 22px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  transition: transform .2s ease;
}
.cv-btn:hover { transform: translateY(-2px) rotate(-2deg); }
.cv-menu { position: relative; }
.cv-menu summary { list-style: none; cursor: pointer; user-select: none; }
.cv-menu summary::-webkit-details-marker { display: none; }
.cv-menu summary span { display: inline-block; margin-left: 4px; transition: transform .2s; }
.cv-menu[open] summary span { transform: rotate(180deg); }
.cv-list {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px;
  background: #fff; border-radius: 14px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.cv-list a {
  display: block; padding: 10px 14px; border-radius: 10px; white-space: nowrap;
  color: #1c1c1c; text-decoration: none; font: 600 13px var(--mono);
}
.cv-list a:hover, .cv-list a:focus-visible { background: #ffd640; }

.hint { display: none; position: fixed; bottom: 16px; right: 16px; z-index: 10; margin: 0; padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.45); color: #fff; font-size: 12px; pointer-events: none; transition: opacity .6s; }
.pan-mode .hint { display: block; }
.hint.hide { opacity: 0; }

@media (max-width: 700px) {
  .toggle { top: auto; bottom: 16px; left: 16px; transform: none; }
  .intro { width: calc(100vw - 24px); }
  .intro p { font-size: 12px; }
  .hint { bottom: 72px; }
  /* phones: the intro fills the top, so the CV button moves to the bottom-right and its menu opens upward */
  .room-cv { top: auto; bottom: 16px; right: 16px; }
  .cv-list { top: auto; bottom: calc(100% + 8px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
