/* Opening show (farewell → glitch → V2) and the 3D café. */

/* ---------- Opening show ---------- */
body.intro-on, body.cafe-on { overflow: hidden; }
.intro { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 32px 16px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #2a1e17 0%, #1c1410 45%, #120d0a 100%); color: #efe3d3; transition: opacity .7s ease, transform .7s ease; }
.intro.out { opacity: 0; transform: scale(1.08); pointer-events: none; }
.intro-card { width: 100%; max-width: 560px; text-align: center; animation: i-rise 1.4s ease-out both; }
.i-logo-wrap { position: relative; width: 170px; height: 170px; margin: 0 auto 26px; }
.i-logo { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 1px solid rgba(212, 168, 122, .55); box-shadow: 0 0 60px rgba(212, 168, 122, .12); }
.i-sign { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%) rotate(-4deg); transform-origin: top center; background: #3a2418; color: #d4a87a;
  border: 1px solid rgba(212, 168, 122, .55); border-radius: 6px; padding: 2px 18px; font-weight: 700; font-size: 15px; letter-spacing: 1px; animation: i-swing 4s ease-in-out infinite; white-space: nowrap; }
.i-sign.open { background: #0f4d2b; color: #b9ffd2; border-color: #4fd18b; box-shadow: 0 0 18px rgba(79, 209, 139, .6); }
.i-steam { position: absolute; top: -46px; left: 50%; width: 40px; height: 50px; transform: translateX(-50%); pointer-events: none; }
.i-steam span { position: absolute; bottom: 0; width: 6px; height: 34px; border-radius: 50%; background: linear-gradient(to top, rgba(212, 168, 122, .35), transparent); filter: blur(3px); animation: i-steam 3.2s ease-in-out infinite; opacity: 0; }
.i-steam span:nth-child(1) { left: 6px; }
.i-steam span:nth-child(2) { left: 17px; animation-delay: 1s; }
.i-steam span:nth-child(3) { left: 28px; animation-delay: 2s; }
.intro h1 { font-family: var(--body); font-size: clamp(26px, 6.5vw, 38px); font-weight: 700; color: #d4a87a; margin-bottom: 16px; line-height: 1.4; }
.i-line { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 0 auto 20px; color: rgba(212, 168, 122, .55); }
.i-line::before, .i-line::after { content: ""; height: 1px; width: 80px; background: rgba(212, 168, 122, .55); }
.intro p { font-size: clamp(15px, 4.1vw, 19px); line-height: 2; }
.intro p + p { margin-top: 8px; }
.intro .muted { color: #b49a80; }
.i-sig { margin-top: 26px; color: #d4a87a; font-weight: 600; font-size: 18px; }
.i-sig small { display: block; color: #b49a80; font-weight: 300; font-size: 14px; margin-top: 4px; }
.intro-skip { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 18px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(212, 168, 122, .3); color: #b49a80; font-size: .85rem; transition: background .2s, color .2s; }
.intro-skip:hover { background: rgba(212, 168, 122, .15); color: #f3e7d7; }

@keyframes i-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes i-swing { 0%, 100% { transform: translateX(-50%) rotate(-4deg); } 50% { transform: translateX(-50%) rotate(3deg); } }
@keyframes i-steam { 0% { transform: translateY(10px) scaleX(1); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-30px) scaleX(2); opacity: 0; } }

/* Glitch layer: scanlines, noise bars and colour tears. */
.intro-noise { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .35) 0 2px, transparent 2px 4px); mix-blend-mode: multiply; }
.intro-bars { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.intro-bars i { position: absolute; left: -5%; width: 110%; display: block; mix-blend-mode: screen; }
.intro.glitching .intro-noise { opacity: 1; animation: gl-flicker .09s steps(2) infinite; }
.intro.glitching .intro-card { animation: gl-shake .14s steps(1) infinite, gl-clip .42s steps(1) infinite; text-shadow: 3px 0 rgba(255, 40, 90, .85), -3px 0 rgba(30, 230, 255, .85); }
.intro.glitching .i-logo { filter: hue-rotate(90deg) contrast(1.6) saturate(2); }
.intro.glitching { animation: gl-flash .6s steps(1) infinite; }
@keyframes gl-shake {
  0% { transform: translate(0, 0); } 20% { transform: translate(-7px, 2px) skewX(7deg); } 40% { transform: translate(6px, -3px); }
  60% { transform: translate(-3px, 1px) skewX(-5deg); } 80% { transform: translate(4px, 3px) scaleY(1.04); } }
@keyframes gl-clip {
  0% { clip-path: inset(0 0 0 0); } 18% { clip-path: inset(12% 0 55% 0); } 30% { clip-path: inset(0 0 0 0); }
  52% { clip-path: inset(48% 0 18% 0); } 64% { clip-path: inset(0 0 0 0); } 84% { clip-path: inset(72% 0 4% 0); } }
@keyframes gl-flicker { 0% { opacity: .9; } 50% { opacity: .4; } }
@keyframes gl-flash { 0%, 100% { filter: none; } 14% { filter: invert(1) hue-rotate(180deg); } 16% { filter: none; } 61% { filter: contrast(2.2) saturate(0); } 63% { filter: none; } }

/* V2 reveal */
.intro-v2 { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; text-align: center; gap: 6px; opacity: 0; pointer-events: none; background: #050302; }
.intro.v2 .intro-card { display: none; }
.intro.v2 .intro-v2 { opacity: 1; pointer-events: auto; cursor: pointer; }
.intro.v2 { animation: none; }
.v2-word { position: relative; font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-weight: 700; font-size: clamp(130px, 38vw, 300px); line-height: 1; letter-spacing: -4px; direction: ltr;
  background: linear-gradient(180deg, #fff3e0 0%, #e9c39a 45%, #a87a4f 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 40px rgba(212, 168, 122, .45)); animation: v2-in .9s cubic-bezier(.2, 1.4, .4, 1) both; }
.v2-word::before, .v2-word::after { content: attr(data-text); position: absolute; inset: 0; -webkit-background-clip: text; background-clip: text; color: transparent; }
.v2-word::before { background-image: linear-gradient(#ff2a5f, #ff2a5f); transform: translateX(-6px); mix-blend-mode: screen; animation: v2-tear 1.6s steps(1) infinite; }
.v2-word::after { background-image: linear-gradient(#21e6ff, #21e6ff); transform: translateX(6px); mix-blend-mode: screen; animation: v2-tear 1.3s steps(1) infinite reverse; }
.v2-sub { font-family: var(--head); font-size: clamp(18px, 4.6vw, 26px); color: #f3e7d7; opacity: 0; animation: i-rise .8s .5s ease-out forwards; }
.v2-tap { margin-top: 14px; font-size: .85rem; color: #8a735e; opacity: 0; animation: i-rise .8s 1.1s ease-out forwards; }
@keyframes v2-in { 0% { opacity: 0; transform: scale(2.4) skewX(-20deg); filter: blur(12px); } 100% { opacity: 1; transform: none; } }
@keyframes v2-tear {
  0% { clip-path: inset(0 0 85% 0); } 15% { clip-path: inset(40% 0 40% 0); } 30% { clip-path: inset(80% 0 2% 0); }
  45% { clip-path: inset(10% 0 70% 0); } 60% { clip-path: inset(55% 0 25% 0); } 80% { clip-path: inset(0 0 100% 0); } }

/* ---------- 3D café ---------- */
.cafe3d { position: fixed; inset: 0; z-index: 60; background: #0b0705; opacity: 0; transition: opacity .8s ease; touch-action: none; user-select: none; -webkit-user-select: none; }
.cafe3d.show { opacity: 1; }
.cafe3d[hidden] { display: none; }
.cafe3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; outline: none; }
.cafe3d canvas.dragging { cursor: grabbing; }
.cafe3d canvas.pointing { cursor: pointer; }
.cafe-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 16px 30px; background: linear-gradient(180deg, rgba(8, 5, 3, .8), transparent); pointer-events: none; }
.cafe-top > * { pointer-events: auto; }
.cafe-brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-size: 1.2rem; color: var(--cream); white-space: nowrap; }
.cafe-brand img { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); }
.cafe-brand b { color: var(--gold-2); font-weight: 600; }
.cafe-brand em { font-style: normal; font-family: var(--body); font-weight: 700; font-size: .75rem; padding: 2px 8px; border-radius: 999px; margin-inline-start: 4px;
  background: linear-gradient(135deg, #e9c39a, #a87a4f); color: #1e130d; direction: ltr; }
.cafe-actions { display: flex; gap: 8px; }
.cafe-btn { position: relative; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 999px; color: var(--cream); font-weight: 600; font-size: .9rem;
  background: rgba(29, 20, 16, .72); border: 1px solid var(--line-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background .2s, border-color .2s, transform .15s; }
.cafe-btn:hover { background: rgba(51, 36, 28, .9); border-color: var(--gold); }
.cafe-btn:active { transform: scale(.96); }
.cafe-btn[hidden] { display: none; }
.cafe-close { background: linear-gradient(135deg, var(--gold-2), var(--gold) 55%, var(--gold-deep)); color: #1e130d; border-color: transparent; }
.cafe-close:hover { background: linear-gradient(135deg, #f3d3ae, var(--gold-2)); }
.cafe-count { position: absolute; top: -4px; left: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; display: none; place-items: center;
  font-size: .72rem; font-weight: 700; background: var(--red); color: #fff; }
.cafe-count.has { display: grid; }
.cafe-mood { position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + 54px); left: 50%; transform: translateX(-50%); z-index: 2; max-width: min(640px, calc(100vw - 32px));
  padding: 6px 14px; border-radius: 999px; font-size: .78rem; text-align: center; color: var(--muted); background: rgba(18, 12, 9, .6); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.cafe-mood:empty { display: none; }
.cafe-hint { position: absolute; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 2; display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 999px; font-size: .86rem; color: var(--cream);
  background: rgba(18, 12, 9, .7); border: 1px solid var(--line-2); backdrop-filter: blur(10px); transition: opacity .6s, transform .6s; pointer-events: none; }
.cafe-hint i { color: var(--gold); animation: hint-swipe 1.8s ease-in-out infinite; }
.cafe-hint.gone { opacity: 0; transform: translate(-50%, 20px); }
@keyframes hint-swipe { 0%, 100% { transform: translateX(-6px); } 50% { transform: translateX(6px); } }
.cafe-tip { position: absolute; z-index: 2; pointer-events: none; padding: 6px 12px; border-radius: 10px; font-size: .82rem; font-weight: 600; white-space: nowrap;
  background: rgba(18, 12, 9, .85); border: 1px solid var(--gold); color: var(--cream); transform: translate(-50%, -140%); opacity: 0; transition: opacity .15s; }
.cafe-tip.show { opacity: 1; }
.cafe-loading { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); background: #0b0705; transition: opacity .6s; }
.cafe-loading.done { opacity: 0; pointer-events: none; }
.cafe-loading .spin { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--gold); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons that bring you back into the café */
.cafe-enter { display: inline-flex; align-items: center; gap: 8px; }
.cafe-enter-row { display: flex; justify-content: center; margin: -10px auto 18px; }
.cafe-enter-btn { display: inline-flex; align-items: center; gap: 10px; padding: 10px 20px; border-radius: 999px; font-weight: 600; color: var(--gold-2);
  background: rgba(212, 168, 122, .1); border: 1px solid rgba(212, 168, 122, .35); transition: background .2s, transform .15s; }
.cafe-enter-btn:hover { background: rgba(212, 168, 122, .2); }
.cafe-enter-btn i { animation: cube-turn 4s ease-in-out infinite; }
@keyframes cube-turn { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(180deg); } }

@media (max-width: 600px) {
  .cafe-brand span { display: none; }
  .cafe-btn { height: 42px; padding: 0 12px; font-size: .85rem; }
  .cafe-mood { top: calc(max(14px, env(safe-area-inset-top)) + 52px); font-size: .72rem; }
  .cafe-hint { font-size: .78rem; padding: 9px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .intro *, .intro { animation: none !important; }
}
