/* ============================================================
   PEPSI-3 — late-night soda bar
   Palette: midnight blue + one Pepsi red + cyan neon
   Type: Bungee (signage) / Space Grotesk (everything else)
   ============================================================ */

:root {
  --bg:        #060d18;
  --bg-2:      #0a1524;
  --surface:   #0d1b2e;
  --surface-2: #12233a;
  --line:      #1d3450;
  --text:      #e9f1fb;
  --muted:     #8ea3bd;
  --red:       #e0313f;
  --red-deep:  #a11226;
  --cyan:      #5fd0ff;
  --green:     #5fe08a;
  --amber:     #ffc45f;
  --font-display: "Bungee", sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --radius: 18px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 78% -10%, #123152 0%, transparent 60%),
    radial-gradient(700px 480px at 8% 108%, #2a1020 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 55%);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* film grain */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ============================== top bar ============================== */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(16px, 4vw, 32px);
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-globe {
  width: 14px; height: 14px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #fff 0 46%, transparent 47%),
    linear-gradient(180deg, var(--red) 48%, #1e3a8a 52%);
  box-shadow: 0 0 14px rgba(224, 49, 63, .7);
  align-self: center; flex: none;
}
.brand-name {
  font-family: var(--font-display);
  font-size: clamp(18px, 3.4vw, 22px);
  letter-spacing: .04em;
  color: var(--text);
  text-shadow: 0 0 22px rgba(224, 49, 63, .55);
}
.brand-tag {
  font-size: 12px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.mode-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
}
.mode-pill i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none;
}
.mode-pill.on i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.mode-pill.busy i { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: pulse 1s ease-in-out infinite; }
.mode-pill b { font-weight: 500; color: var(--muted); }
.mode-pill.on b { color: var(--green); }
@keyframes pulse { 50% { opacity: .35; } }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); border-color: #2c4a6e; }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 21px; height: 21px; fill: var(--text); stroke: none; }
.icon-btn .wave, .icon-btn .spk { fill: var(--text); }
.icon-btn .slash { fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; opacity: 0; }
#muteBtn .wave { transition: opacity .15s; }
#muteBtn.muted .wave { opacity: 0; }
#muteBtn.muted .slash { opacity: 1; }
#muteBtn.muted .spk { opacity: .5; }
#muteBtn { position: relative; }
#muteBtn.muted::after {
  content: ""; position: absolute; left: 9px; right: 9px; top: 50%;
  height: 2.4px; background: var(--red); transform: rotate(-38deg); border-radius: 2px;
}
#muteBtn.muted .wave { display: none; }
#muteBtn.muted .slash { display: none; opacity: 1; }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px;
}

/* ============================== stage layout ============================== */
.stage {
  position: relative; z-index: 2;
  width: min(1080px, 100% - 32px);
  margin: 0 auto; flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr);
  gap: clamp(16px, 3vw, 32px);
  align-items: stretch;
  padding-bottom: 12px;
}
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; width: min(560px, 100% - 24px); }
}

/* ============================== scene ============================== */
.scene {
  position: relative;
  background:
    radial-gradient(120% 90% at 50% 0%, #14335a 0%, transparent 55%),
    linear-gradient(180deg, #0c1c31 0%, #081221 100%);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.05);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 460px;
}

/* hanging neon sign */
.scene-sign {
  position: absolute; top: 18px; left: 22px; z-index: 3;
}
.scene-sign span {
  font-family: var(--font-display);
  font-size: 13px; letter-spacing: .18em;
  color: var(--cyan);
  padding: 8px 14px 6px;
  border: 2px solid rgba(95, 208, 255, .55);
  border-radius: 8px;
  text-shadow: 0 0 12px rgba(95, 208, 255, .9), 0 0 30px rgba(95, 208, 255, .4);
  box-shadow: 0 0 18px rgba(95, 208, 255, .25), inset 0 0 12px rgba(95, 208, 255, .18);
  background: rgba(8, 20, 34, .55);
  animation: signFlicker 6s steps(1) infinite;
}
@keyframes signFlicker {
  0%, 7.9%, 8.4%, 39.9%, 40.6%, 100% { opacity: 1; }
  8%, 8.3%, 40%, 40.5% { opacity: .35; }
}

/* speech bubble */
.bubble {
  position: relative; z-index: 3;
  align-self: flex-start;
  margin: 54px 0 0 clamp(14px, 5%, 40px);
  max-width: min(78%, 340px);
  background: #f4f9ff;
  color: #10233c;
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .7);
  font-size: 15px; font-weight: 500; line-height: 1.4;
}
.bubble p { margin: 0; min-height: 1.4em; }
.bubble::after {
  content: ""; position: absolute; left: 44px; bottom: -10px;
  width: 0; height: 0;
  border: 11px solid transparent; border-top-color: #f4f9ff; border-left-width: 4px;
}
.bubble.speak { animation: bubbleIn .28s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bubbleIn {
  from { transform: translateY(6px) scale(.92); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.bubble.typing::after { border-top-color: transparent; }
.bubble.typing { min-width: 74px; }
.bubble.typing .type-dots { display: inline-flex; gap: 4px; padding: 3px 0; }
.type-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #7d93b3;
  animation: td 1s ease-in-out infinite;
}
.type-dots i:nth-child(2) { animation-delay: .15s; }
.type-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes td { 40% { transform: translateY(-4px); background: #35507a; } }

.robot {
  width: 100%; height: auto; display: block;
  margin-top: -18px;
  flex: 1;
  will-change: transform;
}
.robot #robot, .robot #glassGroup, .robot #canProp { will-change: transform; }

/* caption under scene */
.scene-caption {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 12px;
  font-size: 13px; letter-spacing: .06em;
  color: var(--muted);
  border-top: 1px solid rgba(29, 52, 80, .8);
  background: rgba(6, 13, 24, .5);
}
.scene-caption .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none;
  transition: background .2s;
}
.scene-caption b { color: var(--text); font-weight: 600; letter-spacing: .12em; }
.scene-caption .sep { opacity: .5; }

/* ============================== panel ============================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 26px);
  display: flex; flex-direction: column; gap: 20px;
}

.meter-head { display: flex; justify-content: space-between; align-items: baseline; }
.meter-title { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.meter-val { font-family: var(--font-display); font-size: 20px; color: var(--text); }
.meter {
  position: relative; height: 22px; margin-top: 8px;
  border-radius: 999px; background: #081120;
  border: 1px solid var(--line); overflow: hidden;
}
.meter-fill {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: linear-gradient(90deg, var(--red-deep), var(--red) 60%, #ff6a75);
  border-radius: 999px;
  transition: width .5s cubic-bezier(.3, .9, .4, 1);
}
.meter-fill.low { background: linear-gradient(90deg, #7a4a12, var(--amber)); }
.meter-spark {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, transparent 0 8px, rgba(255,255,255,.08) 8px 10px);
  animation: spark 1.2s linear infinite;
  mix-blend-mode: overlay;
}
@keyframes spark { to { transform: translateX(18px); } }
.meter-hint { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); min-height: 1.3em; }

/* actions */
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  color: var(--text); background: var(--surface-2);
  border: 1px solid #24405f; border-radius: 13px;
  padding: 12px 14px; min-height: 48px; cursor: pointer;
  transition: transform .09s, background .15s, border-color .15s, box-shadow .15s;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn:hover { background: #17304c; border-color: #33587f; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-sip { box-shadow: inset 0 0 0 0 transparent; }
.btn-gulp { background: #3a1220; border-color: #6e2438; }
.btn-gulp:hover { background: #4d1a2b; border-color: #8f3350; }
.btn-refill { background: #0f2e22; border-color: #1f5a43; color: #b8f5d8; }
.btn-refill:hover { background: #14402f; border-color: #2c7a5c; }
.btn-talk { background: var(--red); border-color: #ff6a75; }
.btn-talk:hover { background: #ef4655; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }

/* talk form */
.talk { display: flex; flex-direction: column; gap: 10px; }
.talk-label { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.talk-row { display: flex; gap: 8px; }
.talk-row input {
  flex: 1; min-width: 0;
  font-family: var(--font-body); font-size: 15px; color: var(--text);
  background: #081120; border: 1px solid var(--line); border-radius: 13px;
  padding: 0 14px; min-height: 48px;
  transition: border-color .15s;
}
.talk-row input::placeholder { color: #5d7291; }
.talk-row input:focus { border-color: var(--cyan); outline: none; }
.talk-row .btn-talk { flex: none; padding: 0 18px; }

/* log */
.log {
  display: flex; flex-direction: column-reverse; gap: 8px;
  max-height: 180px; overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: #24405f transparent;
}
.log:empty { display: none; }
.log-line {
  display: flex; gap: 8px; font-size: 14px; line-height: 1.45;
  animation: logIn .25s ease-out;
}
@keyframes logIn { from { opacity: 0; transform: translateY(5px); } }
.log-line .who { flex: none; font-weight: 700; letter-spacing: .02em; }
.log-line.user .who { color: var(--cyan); }
.log-line.robot .who { color: var(--red); }
.log-line .txt { color: #c6d5ea; overflow-wrap: anywhere; }
.log-line.robot .txt { color: var(--text); }

/* ============================== footer ============================== */
.foot {
  position: relative; z-index: 2;
  width: min(1080px, 100% - 32px);
  margin: 8px auto 20px;
  padding: 14px 4px 0;
  border-top: 1px solid rgba(29, 52, 80, .6);
  font-size: 13px; color: var(--muted);
  display: flex; flex-direction: column; gap: 4px;
}
.foot b { color: var(--text); }
.foot-credits { font-size: 12px; opacity: .75; }

/* ============================== modal ============================== */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-back { position: absolute; inset: 0; background: rgba(4, 9, 16, .72); backdrop-filter: blur(3px); }
.modal-card {
  position: relative;
  width: min(460px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid #27476b; border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  animation: modalIn .25s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes modalIn { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.modal-card h2 {
  margin: 0 0 8px; font-family: var(--font-display); font-size: 20px;
  letter-spacing: .03em; font-weight: 400;
}
.modal-sub { margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.modal-sub code, .modal-sub b { color: var(--text); font-weight: 600; }
.field { display: block; margin-bottom: 12px; }
.field span {
  display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.field input {
  width: 100%; font-family: var(--font-body); font-size: 15px; color: var(--text);
  background: #081120; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; min-height: 44px;
}
.field input:focus { border-color: var(--cyan); outline: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.modal-status { min-height: 1.3em; font-size: 13.5px; margin: 12px 0 0; }
.modal-status.ok { color: var(--green); }
.modal-status.err { color: #ff8b96; }
.modal-status.wait { color: var(--amber); }

/* ============================== motion prefs ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001s !important;
  }
}
