/* Live demo stage: phone, week calendar, owner feed */

.demo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 24px;
}

.demo-note {
  margin: 0;
}

.demo-inner {
  padding: 0;
}

.demo-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.demo-live {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.demo-status {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 16.5px;
  letter-spacing: -0.01em;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-step {
  color: var(--accent);
  flex: none;
}

.demo-status-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-clock {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}

.demo-clock-time {
  color: var(--bone);
}

.demo-clock-state {
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--ash);
}

.demo-clock-state.is-open {
  color: var(--ok);
}

.demo-progress {
  height: 2px;
  background: var(--line-soft);
}

.demo-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s linear;
}

.demo-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 28px;
  padding: 24px;
}

.demo-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.demo-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 16px;
}

.demo-label-r {
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-col-phone {
  --phone-fs: 15px;
  align-items: center;
  width: calc(20.5 * var(--phone-fs));
  flex: none;
}

.demo-col-phone .demo-label {
  align-self: stretch;
}

@media (min-width: 1024px) {
  .demo-col-phone {
    --phone-fs: clamp(11.5px, calc((100vh - 360px) / 44.4), 14px);
  }
}

.demo-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.demo-ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--bone);
  transition: border-color 0.2s, color 0.2s;
}

.demo-ctl:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.demo-ctl svg {
  width: 14px;
  height: 14px;
}

.demo-ctl[data-act="toggle"] {
  min-width: 118px;
}

.demo-ctl .i-play {
  display: none;
}

.demo-ctl[data-paused="true"] .i-pause {
  display: none;
}

.demo-ctl[data-paused="true"] .i-play {
  display: block;
}

.demo-speed {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.demo-speed button {
  min-width: 36px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ash);
  transition: color 0.2s, background-color 0.2s;
}

.demo-speed button[aria-pressed="true"] {
  background: var(--bone);
  color: var(--ink);
}

.demo-side {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 28px;
  min-width: 0;
}

.demo-side-nav {
  display: none;
}

/* ---------- Calendar ---------- */

.cal {
  --colw: 160px;
  --hourh: 50px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  font-family: var(--font-sans);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.cal-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.cal-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

.cal-key {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-left: 8px;
}

.cal-key--busy {
  background: var(--elev-2);
  border: 1px solid var(--line);
}

.cal-key--free {
  border: 1px dashed var(--ok);
}

.cal-key--new {
  background: var(--info);
}

.cal-body {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.cal-gutter {
  position: relative;
  flex: none;
  width: 48px;
  margin-top: 25px;
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.cal-hours {
  position: relative;
  top: 7px;
  height: 100%;
  transform: translateY(var(--cal-y, 0px));
  transition: transform 0.9s var(--ease-out);
}

.cal-hour {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ash);
  white-space: nowrap;
}

.cal-view {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.cal-track {
  position: relative;
  transition: transform 0.9s var(--ease-out);
  will-change: transform;
}

.cal-dayrow {
  position: relative;
  z-index: 3;
  display: flex;
  height: 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.cal-day {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--colw);
  flex: none;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  transition: color 0.3s;
}

.cal-day.is-today {
  color: var(--bone);
}

.cal-day.is-today::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
}

.cal-grid {
  position: relative;
  display: flex;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hourh);
  transform: translateY(var(--cal-y, 0px));
  transition: transform 0.9s var(--ease-out);
}

.cal-col {
  position: relative;
  width: var(--colw);
  flex: none;
  border-right: 1px solid var(--line-soft);
  transition: background-color 0.5s;
}

.cal-col.is-focus {
  background: rgb(255 255 255 / 0.035);
}

.cal-col.is-closed::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 6px, hsl(0 0% 100% / 0.025) 6px 7px);
  pointer-events: none;
}

.cal-closed-chip {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  z-index: 2;
}

.cal-ev {
  position: absolute;
  left: 5px;
  right: 5px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--elev-2);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.25;
  color: var(--bone-70);
  overflow: hidden;
  box-sizing: border-box;
  transition: background-color 0.4s, border-color 0.4s, color 0.4s, opacity 0.4s;
}

.cal-ev b {
  font-weight: 500;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-ev span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ash);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-ev span svg {
  width: 11px;
  height: 11px;
}

.cal-ev--short {
  padding: 3px 8px;
  justify-content: center;
}

.cal-ev--short span {
  display: none;
}

.cal-ev--break {
  background: transparent;
  border-style: dashed;
  color: var(--ash);
}

.cal-ev--break b {
  color: var(--ash);
}

.cal-ev--free {
  background: var(--ok-20);
  border: 1px dashed var(--ok);
  color: var(--ok);
  animation: cal-free-in 0.5s var(--ease-out) both, cal-free-pulse 1.8s ease-in-out 0.5s 2;
}

.cal-ev--free b,
.cal-ev--free span {
  color: var(--ok);
}

.cal-ev--free.is-picked {
  border-style: solid;
  box-shadow: 0 0 0 2px hsl(152 60% 48% / 0.35);
}

.cal-ev--free.is-dim {
  opacity: 0.35;
}

.cal-ev--new {
  background: var(--info-20);
  border: 1px solid var(--info);
  animation: cal-free-in 0.45s var(--ease-out) both;
}

.cal-ev--new b {
  color: var(--bone);
}

.cal-ev--new span {
  color: var(--info);
}

.cal-ev--new.is-confirmed {
  background: var(--ok-20);
  border-color: var(--ok);
}

.cal-ev--new.is-confirmed span {
  color: var(--ok);
}

.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 2;
}

.cal-now::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18%;
  background: linear-gradient(to bottom, transparent, rgb(255 255 255 / 0.22));
  border-bottom: 1px solid var(--accent);
  animation: cal-scan 1.1s var(--ease-out) both;
  pointer-events: none;
  z-index: 1;
}

.cal-hold {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--bone);
  z-index: 3;
  animation: cal-free-in 0.45s var(--ease-out) both;
}

.cal-hold i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex: none;
}

.cal.is-static .cal-track,
.cal.is-static .cal-grid,
.cal.is-static .cal-hours,
.cal.is-static .cal-ev,
.cal.is-static .cal-hold {
  transition: none !important;
  animation: none !important;
}

/* ---------- Owner feed ---------- */

.feed {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  min-height: 320px;
}

.feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

.feed-count b {
  font-weight: 400;
  color: var(--bone);
  margin-right: 2px;
}

.feed-count--you b {
  color: var(--danger);
}

.feed-list {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 0;
}

.feed-slot {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.55s var(--ease-out);
}

.feed-slot.is-in {
  grid-template-rows: 1fr;
}

.feed-slot > * {
  min-height: 0;
}

.feed-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 12px 12px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--elev);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.5s var(--ease-out) 0.1s, transform 0.5s var(--ease-out) 0.1s;
}

.feed-slot.is-in .feed-card {
  opacity: 1;
  transform: none;
}

.feed-ic {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--ok);
}

.feed-ic svg {
  width: 14px;
  height: 14px;
}

.feed-card--info .feed-ic {
  color: var(--info);
}

.feed-card--danger {
  border-color: hsl(0 70% 56% / 0.5);
  background: hsl(0 70% 56% / 0.06);
}

.feed-card--danger .feed-ic {
  color: var(--danger);
  border-color: hsl(0 70% 56% / 0.5);
}

.feed-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.feed-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--bone);
}

.feed-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ash);
}

.feed-time {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}

.feed-attach {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 8px;
  border-left: 2px solid var(--line);
  background: var(--surface);
  border-radius: 0 6px 6px 0;
}

.feed-attach-msg {
  font-size: 13px;
  line-height: 1.4;
  color: var(--bone-70);
}

.feed-attach-msg--bot {
  color: var(--ash);
}

.feed-action {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  margin-top: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--bone);
}

.feed-empty {
  position: absolute;
  inset: 44px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 24px;
  text-align: center;
  font-size: 15px;
  color: var(--ash);
  transition: opacity 0.4s;
}

.feed-empty span:first-child {
  font-family: var(--font-display);
  font-size: 16.5px;
  color: var(--bone-70);
}

.feed.has-cards .feed-empty {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Static (seeked) ---------- */

.demo-stage.is-static .feed-slot,
.demo-stage.is-static .feed-card,
.demo-stage.is-static .demo-progress span {
  transition: none !important;
}

/* ---------- Keyframes ---------- */

@keyframes cal-free-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

@keyframes cal-free-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 hsl(152 60% 48% / 0);
  }
  50% {
    box-shadow: 0 0 0 4px hsl(152 60% 48% / 0.25);
  }
}

@keyframes cal-scan {
  from {
    top: 0;
  }
  to {
    top: 82%;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1279px) {
  .demo-side {
    grid-template-columns: minmax(0, 1fr);
  }

  .feed {
    min-height: 240px;
  }
}

@media (max-width: 900px) {
  .demo-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
  }

  .demo-live {
    order: 1;
  }

  .demo-clock {
    order: 2;
    font-size: 12px;
    padding: 5px 10px;
  }

  .demo-status {
    order: 3;
    white-space: normal;
    overflow: visible;
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .demo-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 16px;
  }

  .demo-col-phone {
    --phone-fs: 13px;
    width: auto;
  }

  .demo-side {
    display: flex;
    overflow: hidden;
    gap: 0;
  }

  .demo-side > .demo-col {
    flex: none;
    width: 100%;
    transition: transform 0.6s var(--ease-out);
  }

  .demo-side[data-show="feed"] > .demo-col {
    transform: translateX(-100%);
  }

  .demo-side-nav {
    display: inline-flex;
    gap: 6px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    justify-self: center;
  }

  .demo-side-nav button {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--ash);
  }

  .demo-side-nav button[aria-pressed="true"] {
    background: var(--bone);
    color: var(--ink);
  }

  .cal-body {
    max-height: 330px;
  }

  .cal-track {
    transition: transform 0.9s var(--ease-out);
  }

  .feed {
    min-height: 200px;
  }
}

@media (max-width: 480px) {
  .demo-status {
    font-size: 15px;
  }

  .demo-note {
    display: none;
  }
}

/* ---------- Review fixes ---------- */

/* The step label keeps its width, so the status sentence never jumps sideways */
.demo-step {
  display: inline-block;
  min-width: 11ch;
}

/* Owner feed column fills the same height as the calendar */
.demo-side {
  align-items: stretch;
}

.demo-col-feed .feed {
  flex: 1;
}

/* Hand-off: the untouched calendar dims behind the callout */
.cal .cal-view,
.cal .cal-gutter {
  transition: opacity 0.4s var(--ease-std);
}

.cal.is-holding .cal-view,
.cal.is-holding .cal-gutter {
  opacity: 0.4;
}

.demo-after {
  margin-top: 20px;
}

@media (max-width: 900px) {
  /* Two-line status reserved, so the stage does not grow mid-play */
  .demo-status {
    min-height: 4.6em;
  }

  /* Calendar / Owner feed switch sits right under the phone */
  .demo-side-nav {
    order: 1;
  }

  .demo-side {
    order: 2;
  }

  /* Cross-fade the two panels instead of a hard slide; labels never touch */
  .demo-side > .demo-col {
    transition: transform 0.6s var(--ease-out), opacity 0.35s var(--ease-std);
  }

  .demo-side:not([data-show="feed"]) > .demo-col-feed,
  .demo-side[data-show="feed"] > .demo-col-cal {
    opacity: 0;
  }
}

@media (pointer: coarse) {
  .demo-ctl,
  .demo-side-nav button {
    min-height: 44px;
  }

  .demo-speed button {
    min-height: 44px;
    min-width: 44px;
  }
}
