/* Troy web simulator (simulator.html): one working iPhone on the site's paper.
   Loaded after tokens.css, nav.css, tool.css and phone.css. The phone, the bubbles, the tails, the typing dots,
   "Delivered" and the tapback badge are phone.css; this file only adds what a phone you can really type into
   needs (a status bar, a real text field, the plus menu, poll and card bubbles, the tapback picker) and the
   page around it. Colors and fonts are the palette in tokens.css. Motion is opacity and transform only. */

/* ---------- Page: the dashboard's header (painting band, nav on it, title plaque, Greek key) ---------- */
/* Same measures as the staff page (officium.css), which is scoped to that page. */
.sim-page { overflow-x: hidden; }
.sim-page .band { position: relative; height: clamp(190px, 26vh, 250px); overflow: hidden; background: var(--line); }
.sim-page .band img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 58%; }
.sim-page .site-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  max-width: 1128px;
  margin: 0 auto;
  padding: 10px 24px 0;
  color: var(--ink);
}
.sim-page .site-head .site-nav-brand,
.sim-page .site-head .site-nav-links { color: var(--ink); background: rgba(var(--paper-rgb), 0.9); border-radius: var(--r-pill); }
.sim-page .site-head .site-nav-brand { padding: 0 18px; }
.sim-page .site-head .site-nav-links { margin-right: 0; padding: 0 6px; }
.sim-page .site-head .site-nav-links a { color: var(--stone); }
.sim-page .site-head .site-nav-links a:hover,
.sim-page .site-head .site-nav-links a[aria-current="page"] { color: var(--ink); }

.sim-page .wrap { max-width: 1128px; }
.sim-page .page-head {
  position: relative;
  margin-top: -76px;
  padding: 22px 30px 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: inset 0 0 0 5px var(--paper), inset 0 0 0 6px var(--line), var(--shadow-soft);
}
.sim-page .page-head::before { width: 64px; height: 24px; margin: 0 0 8px -3px; }
.sim-page .page-head h1 { font-size: clamp(2rem, 3.6vw, 2.75rem); }
.sim-for {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  font-size: 1.375rem;
  line-height: 1.2;
}
.sim-page .page-head .sub { margin-top: 10px; font-size: 13px; }
.sim-page .key-rule { margin: 18px 0 16px; }

.sim-stage { display: flex; justify-content: center; padding: 12px 0 8px; }

/* ---------- The phone, at a size you can use ---------- */
.sim-phone {
  width: min(390px, 100%);
  height: min(800px, max(560px, calc(100vh - 48px)));
  height: min(800px, max(560px, calc(100dvh - 48px)));
}
.sim-phone .phone-screen { font-size: 16px; }

/* Status bar: the time and the three glyphs on either side of the island. */
.sim-statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding: 0 26px 0 32px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  pointer-events: none;
}
.sim-status-icons { display: flex; align-items: center; gap: 5px; }
.sim-status-icons svg { display: block; fill: currentColor; }

.sim-phone .msg-header { position: relative; padding-top: 46px; }
.sim-phone .msg-avatar { width: 46px; height: 46px; }
.sim-phone .msg-name { font-size: 12px; }
/* The name's small chevron, as in Messages. */
.sim-phone .msg-name::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 0 1px 4px;
  border-top: 1.5px solid var(--stone);
  border-right: 1.5px solid var(--stone);
  transform: rotate(45deg);
}
/* The back chevron. Drawn only: there is no list of chats to go back to. */
.sim-back {
  position: absolute;
  left: 18px;
  top: 62px;
  width: 12px;
  height: 12px;
  border-left: 2.5px solid var(--imessage-blue);
  border-bottom: 2.5px solid var(--imessage-blue);
  border-radius: 1px;
  transform: rotate(45deg);
}

.sim-phone .msg-list { padding: 10px 14px 8px; overscroll-behavior: contain; scroll-behavior: smooth; }
.sim-phone .msg-list:focus-visible { outline-offset: -3px; }
.sim-phone .bubble { max-width: 76%; padding: 7px 13px; white-space: pre-wrap; line-height: 1.3; }
.sim-phone .msg-note, .sim-phone .msg-status { font-size: 11px; }
.sim-phone .msg-note b { font-weight: 600; }
.sim-phone .msg-note:first-child { margin-top: 2px; }

/* Bubbles come in the way they do in Messages: a short rise. */
@keyframes sim-in { from { opacity: 0; transform: translateY(6px); } }
.sim-phone .msg-list > * { animation: sim-in 180ms ease-out; }

/* Typing dots, moving. */
@keyframes sim-dot { 0%, 60%, 100% { opacity: 0.35; } 30% { opacity: 1; } }
.sim-phone .typing { margin-top: 8px; padding: 13px 14px; }
.sim-phone .typing i { width: 8px; height: 8px; animation: sim-dot 1.2s infinite both; }
.sim-phone .typing i:nth-child(2) { animation-delay: 0.2s; }
.sim-phone .typing i:nth-child(3) { animation-delay: 0.4s; }

/* A message that did not go: the red mark beside it and the line under it. */
.sim-phone .bubble.is-failed { margin-right: 26px; }
.sim-phone .bubble.is-failed .sim-bang {
  position: absolute;
  right: -30px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cardinal);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}
.sim-phone .msg-status.is-failed { color: var(--cardinal); font-weight: 600; }
/* "Edited", under one of Troy's bubbles. */
.sim-phone .msg-status.is-edited { align-self: flex-start; margin: 1px 0 0 4px; color: var(--imessage-blue); }

/* Photos, sent or received: rounded, whole picture, no tail. */
.sim-phone .bubble.is-photo { padding: 0; background: none; line-height: 0; max-width: 68%; }
.sim-phone .bubble.is-photo img { display: block; width: 100%; height: auto; max-height: 280px; object-fit: cover; border-radius: 18px; background: var(--line); }
.sim-phone .bubble.is-photo.tail::before,
.sim-phone .bubble.is-photo.tail::after { content: none; }
.sim-phone .bubble.is-photo .tapback { line-height: 1; }

/* Card bubbles: the contact card, a location, a location request. */
.sim-phone .bubble.is-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
  padding: 10px 12px;
  white-space: normal;
}
.sim-card-pic { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--white); object-fit: cover; }
.sim-card-words { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sim-card-words b { font-weight: 600; }
.sim-card-words small { font-size: 12px; opacity: 0.7; }
.sim-card-chev { flex: none; width: 7px; height: 7px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; opacity: 0.4; transform: rotate(45deg); }
/* The pin: a round head and a point. */
.sim-pin { flex: none; position: relative; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); }
.bubble.from-them .sim-pin { background: var(--white); }
.sim-pin::before { content: ""; position: absolute; left: 13px; top: 9px; width: 14px; height: 14px; border-radius: 50% 50% 50% 0; background: currentColor; transform: rotate(-45deg); }
.sim-pin::after { content: ""; position: absolute; left: 18px; top: 14px; width: 4px; height: 4px; border-radius: 50%; background: var(--imessage-blue); }
.bubble.from-them .sim-pin { color: var(--imessage-blue); }
.bubble.from-them .sim-pin::after { background: var(--white); }
.sim-card-btn {
  margin-top: 6px;
  align-self: flex-start;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--imessage-blue);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
}

/* Poll bubble: a white-on-gray card, one row per option with a round check and a count. */
.sim-phone .bubble.is-poll {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 80%;
  max-width: 80%;
  padding: 10px;
  white-space: normal;
}
.sim-poll-label { padding: 0 4px 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--stone); }
.sim-poll-q { padding: 0 4px 4px; font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.sim-poll-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 7px 12px 7px 10px;
  border: 0;
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  text-align: left;
  overflow: hidden;
}
.sim-poll-opt .tick { flex: none; position: relative; width: 20px; height: 20px; border: 1.5px solid var(--stone); border-radius: 50%; }
.sim-poll-opt[aria-pressed="true"] .tick { border-color: var(--imessage-blue); background: var(--imessage-blue); }
.sim-poll-opt[aria-pressed="true"] .tick::after { content: ""; position: absolute; left: 6px; top: 2.5px; width: 4px; height: 9px; border-right: 2px solid var(--white); border-bottom: 2px solid var(--white); transform: rotate(45deg); }
.sim-poll-opt .words { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sim-poll-opt .n { flex: none; font-size: 13px; font-weight: 600; color: var(--stone); font-variant-numeric: tabular-nums; }
.sim-poll-opt[aria-pressed="true"] .n { color: var(--imessage-blue); }

/* Tapbacks. The badge is phone.css; here are the glyphs that are words, and the picker. */
.sim-phone .tapback { z-index: 1; color: var(--white); font-weight: 700; }
.sim-phone .bubble.from-me .tapback { color: var(--ink); }
.sim-phone .tapback.is-word { font-size: 9px; letter-spacing: -0.02em; }
/* The small button that opens the picker. It shows on hover and on keyboard focus; touch uses a long press. */
.sim-react {
  position: absolute;
  top: 50%;
  right: -34px;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--stone);
  font-size: 13px;
  line-height: 1;
  opacity: 0;
}
.sim-react::before { content: "\2661"; }
.bubble:hover > .sim-react, .sim-react:focus-visible, .bubble.is-picking > .sim-react { opacity: 1; }
@media (hover: none) { .sim-react { display: none; } }
.sim-phone .bubble.from-them { -webkit-touch-callout: none; }

.sim-picker {
  position: absolute;
  z-index: 5;
  display: flex;
  gap: 2px;
  padding: 5px 7px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-soft);
  animation: sim-in 140ms ease-out both;
}
.sim-picker button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--stone);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.sim-picker button.is-word { font-size: 10px; letter-spacing: -0.02em; }
.sim-picker button:hover { background: var(--bubble-gray); }
.sim-picker button[aria-pressed="true"] { background: var(--imessage-blue); color: var(--white); }

/* ---------- The input bar ---------- */
.sim-compose { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 6px 12px 4px; }
.sim-plus-wrap { position: relative; flex: none; }
.sim-plus {
  position: relative;
  display: block;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bubble-gray);
}
.sim-plus::before, .sim-plus::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--stone); border-radius: 1px; }
.sim-plus::before { width: 14px; height: 2px; margin: -1px 0 0 -7px; }
.sim-plus::after { width: 2px; height: 14px; margin: -7px 0 0 -1px; }
.sim-phone .msg-input { flex: 1; min-width: 0; min-height: 36px; margin: 0; padding: 3px 4px 3px 14px; align-items: flex-end; }
.sim-phone .msg-input-text {
  display: block;
  align-self: center;
  width: 100%;
  max-height: 110px;
  margin: 0;
  padding: 4px 0;
  border: 0;
  outline: 0;
  background: none;
  resize: none;
  font: inherit;
  font-size: 16px;      /* 16px keeps phone browsers from zooming in on focus */
  line-height: 1.3;
  color: var(--ink);
  scrollbar-width: none;
}
.sim-phone .msg-input-text::placeholder { color: var(--stone); opacity: 1; }
.sim-phone .msg-input:focus-within { border-color: var(--stone); }
.sim-phone .msg-send { pointer-events: auto; width: 28px; height: 28px; cursor: pointer; }
.sim-phone .msg-send::before { top: 9px; }
.sim-phone .msg-send::after { top: 9px; }
.sim-phone .msg-send:disabled { background: var(--bubble-gray); cursor: default; }
.sim-phone .msg-send:focus-visible, .sim-plus:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* The plus menu: two rows, above the button. */
.sim-menu {
  position: absolute;
  left: 0;
  bottom: 44px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  min-width: 210px;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  animation: sim-in 140ms ease-out both;
}
.sim-menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: none;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.sim-menu button:hover { background: var(--paper); }
.sim-menu-ico { position: relative; flex: none; width: 28px; height: 28px; border-radius: 50%; }
.sim-menu-ico.is-photo { background: var(--line); }
.sim-menu-ico.is-photo::before { content: ""; position: absolute; left: 6px; top: 8px; width: 16px; height: 12px; border: 2px solid var(--stone); border-radius: 3px; box-sizing: border-box; }
.sim-menu-ico.is-photo::after { content: ""; position: absolute; left: 12px; top: 12px; width: 4px; height: 4px; border-radius: 50%; background: var(--stone); }
.sim-menu-ico.is-location { background: var(--laurel-soft); color: var(--laurel); }
.sim-menu-ico.is-location::before { content: ""; position: absolute; left: 9px; top: 7px; width: 10px; height: 10px; border-radius: 50% 50% 50% 0; background: currentColor; transform: rotate(-45deg); }

/* A photo waiting to be sent, above the input bar. */
.sim-attach { flex: none; display: flex; padding: 6px 14px 0 56px; }
.sim-attach-box { position: relative; }
.sim-attach img { display: block; max-width: 120px; max-height: 96px; border-radius: 14px; border: 1px solid var(--line); }
.sim-attach button {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--stone);
  color: var(--white);
  font-size: 14px;
  line-height: 1;
}

.sim-homebar { flex: none; width: 124px; height: 5px; margin: 6px auto 8px; border-radius: var(--r-pill); background: var(--ink); }

/* ---------- The leave dialog ---------- */
.sim-leave {
  width: min(420px, calc(100vw - 32px));
  padding: 26px 26px 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 5px var(--paper), inset 0 0 0 6px var(--line), var(--shadow-phone);
  font-family: var(--font-body);
}
.sim-leave::backdrop { background: rgba(var(--ink-rgb), 0.45); }
.sim-leave p { margin: 0; font-size: 17px; line-height: 1.45; text-wrap: pretty; }
.sim-leave-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media (max-width: 620px) {
  .sim-page .band { height: 132px; }
  .sim-page .site-head { padding: 6px 8px 0; }
  .sim-page .site-head .site-nav-links { padding: 0 2px; }
  .sim-page .page-head { margin-top: -44px; padding: 16px 18px 18px; border-radius: 26px; }
  .sim-page .page-head::before { width: 54px; height: 20px; margin-bottom: 6px; }
  .sim-page .page-head h1 { font-size: 1.75rem; }
  .sim-for { font-size: 1.125rem; }
  .sim-page .key-rule { margin: 14px 0 12px; }
  .sim-stage { padding-top: 4px; }
  .sim-phone { border-radius: 44px; padding: 8px; height: min(760px, max(520px, calc(100dvh - 24px))); }
  .sim-phone .phone-screen { border-radius: 36px; }
  .sim-leave-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sim-phone .msg-list { scroll-behavior: auto; }
  .sim-phone .msg-list > *, .sim-picker, .sim-menu { animation: none; }
  .sim-phone .typing i { animation: none; }
}
