/*
 * Students Congress registration chat.
 * Chat-app layout in the Students Congress poster identity: deep violet,
 * metallic gold, a magenta date badge, the heavy rounded wordmark, and the
 * violet-and-gold rings. The ticket is the one bold piece.
 */

@font-face {
  font-family: "Noto Sans Malayalam";
  src: url("fonts/noto-sans-malayalam-malayalam-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap; unicode-range: U+0307, U+0323, U+0951-0952, U+0964-0965, U+0D00-0DFF, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Noto Sans Malayalam";
  src: url("fonts/noto-sans-malayalam-malayalam-600-normal.woff2") format("woff2");
  font-weight: 600; font-display: swap; unicode-range: U+0307, U+0323, U+0951-0952, U+0964-0965, U+0D00-0DFF, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Noto Sans Malayalam";
  src: url("fonts/noto-sans-malayalam-malayalam-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap; unicode-range: U+0307, U+0323, U+0951-0952, U+0964-0965, U+0D00-0DFF, U+200C-200D, U+25CC;
}
@font-face {
  /* Subset to the greeting only */
  font-family: "SC Naskh";
  src: url("fonts/noto-naskh-arabic-greeting.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  /* Wordmark, date and ticket number: heavy rounded face close to the poster */
  font-family: "Russo One";
  src: url("fonts/russo-one-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}

:root {
  /* Poster palette */
  --violet: #33208a;          /* overridden by brand_color via --brand */
  --violet-deep: #1d1155;
  --gold: #d9952b;
  --gold-ink: #9a5f0c;        /* gold readable as text on the light page */
  --gold-metal: linear-gradient(180deg, #f7d47e 0%, #e3a136 48%, #b8660f 100%);
  --magenta: #a3236f;         /* the date badge */
  --pin: #e0393e;

  --bg: #f8f7f4;
  --surface: #f1eef8;
  --text: #17122e;
  --muted: #5f5a72;
  --border: #e5e1ee;
  --bubble: #ece7f8;
  --composer: #ffffff;
  --chip-hover: #f3f0fb;
  --btn: var(--brand);
  --btn-text: #ffffff;
  --btn-off: #d9d4e6;
  --card: #ffffff;
  --danger: #b3261e;
  --ok: #17784b;
  --shadow: 0 1px 2px rgba(23, 18, 46, .05), 0 10px 28px -14px rgba(51, 32, 138, .28);
  --brand: var(--violet);
  --brand-text: var(--violet);
  --brand-tint: rgba(51, 32, 138, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Malayalam", sans-serif;
  --display: "Russo One", var(--font);
  --rings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300' viewBox='0 0 300 300'%3E%3Ccircle cx='150' cy='150' r='118' fill='none' stroke='%2333208a' stroke-opacity='.9' stroke-width='34'/%3E%3Ccircle cx='150' cy='150' r='118' fill='none' stroke='%239b86e8' stroke-opacity='.55' stroke-width='10'/%3E%3Ccircle cx='150' cy='150' r='80' fill='none' stroke='%23d9952b' stroke-width='14'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110b24; --surface: #1a1236; --text: #eeeaf9; --muted: #a49cbd; --border: #2a2148; --bubble: #261c4c;
    --composer: #19122f; --chip-hover: #1f1640; --btn-text: #ffffff; --btn-off: #352b57;
    --card: #160f2c; --danger: #ff8a80; --ok: #6fd49d; --gold-ink: #f0c46a; --brand-text: #b8a6ff;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 12px 30px -14px rgba(0, 0, 0, .7);
    --brand-tint: rgba(184, 166, 255, .12);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #110b24; --surface: #1a1236; --text: #eeeaf9; --muted: #a49cbd; --border: #2a2148; --bubble: #261c4c;
  --composer: #19122f; --chip-hover: #1f1640; --btn-text: #ffffff; --btn-off: #352b57;
  --card: #160f2c; --danger: #ff8a80; --ok: #6fd49d; --gold-ink: #f0c46a; --brand-text: #b8a6ff;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 12px 30px -14px rgba(0, 0, 0, .7);
  --brand-tint: rgba(184, 166, 255, .12);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
:lang(ml) body, body:lang(ml) { line-height: 1.8; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Shell ---------------------------------------------------------- */
.app {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--bg);
}
.app[data-state="chat"] .topbar { box-shadow: 0 1px 0 var(--border); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand img { height: 30px; width: auto; flex: none; }
:root[data-theme="dark"] .brand img { box-sizing: content-box; background: #fff; border-radius: 8px; padding: 3px 7px; height: 28px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand img { box-sizing: content-box; background: #fff; border-radius: 8px; padding: 3px 7px; height: 28px; } }
.brand span {
  font-weight: 700; font-size: 17px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px;
  border: 0; background: transparent; border-radius: 12px; cursor: pointer; color: var(--text); padding: 0 8px;
}
.icon-btn:hover { background: var(--chip-hover); }
.icon-btn svg { width: 21px; height: 21px; }
.lang { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 3px; }
.lang button {
  border: 0; background: transparent; border-radius: 999px; min-height: 36px; padding: 0 12px;
  cursor: pointer; font-size: 14px; color: var(--muted);
}
.lang button[aria-pressed="true"] { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 31, 25, .12); }

.progress { height: 3px; background: transparent; position: sticky; top: 60px; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--magenta), var(--gold)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.app[data-state="empty"] .progress { visibility: hidden; }

.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.column { max-width: 768px; margin: 0 auto; padding: 0 16px; }

/* ---- Empty state: the poster ------------------------------------- */
.app[data-state="empty"] {
  background-image: var(--rings); background-repeat: no-repeat;
  background-position: right -104px top -104px; background-size: 210px 210px;
}
.app[data-state="empty"] .topbar { background: transparent; }
.app[data-state="empty"] .icon-btn { background: var(--card); box-shadow: 0 1px 3px rgba(23, 18, 46, .14); border-radius: 50%; }
.hero { text-align: center; padding: 8px 16px 4px; }
.wordmark {
  font-family: var(--display); font-weight: 400; text-transform: uppercase; line-height: .9;
  margin: 10px 0 18px; display: flex; flex-direction: column; align-items: center; color: var(--brand-text);
}
.wordmark span { display: block; font-size: clamp(46px, 13.5vw, 76px); letter-spacing: .005em; }
.wordmark .wm-small { font-size: clamp(34px, 9.6vw, 54px); }
.wordmark .wm-gold {
  background: var(--gold-metal); -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-bottom: .04em;
}
.event-badge {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 22px;
  margin: 0 auto 18px; text-align: left;
}
.eb-date, .eb-where { display: flex; align-items: center; gap: 10px; }
.eb-day {
  font-family: var(--display); font-size: 30px; line-height: 1; color: #fff; background: var(--magenta);
  border-radius: 12px; min-width: 56px; height: 56px; display: grid; place-items: center; padding: 0 8px;
}
.eb-when strong, .eb-where strong { display: block; font-weight: 800; text-transform: uppercase; letter-spacing: .01em; line-height: 1.15; }
.eb-when strong { font-size: 17px; }
.eb-when > span { display: block; font-weight: 700; text-transform: uppercase; font-size: 14px; color: var(--muted); }
.eb-where svg { width: 26px; height: 26px; color: var(--pin); flex: none; }
.eb-where strong { font-size: 19px; color: var(--brand-text); }
.eb-where strong + span { display: block; font-size: 13px; color: var(--muted); }
.hero .greet { margin: 0 auto 6px; max-width: 30rem; color: var(--muted); line-height: 1.5; }
.app[data-state="empty"] .scroll { flex: 0 0 auto; margin-top: auto; overflow: visible; }
.app[data-state="empty"] .dock { margin-bottom: auto; background: transparent; }
.app[data-state="empty"] .log { display: none; }
.app[data-state="chat"] .hero { display: none; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.app[data-state="chat"] .suggestions { display: none; }

/* Arabic greeting: larger, right-to-left inside, block stays where the text is. */
.ar {
  display: block; font-family: "SC Naskh", "Noto Naskh Arabic", "Geeza Pro", "Damascus", serif;
  font-size: 1.3em; line-height: 2; direction: rtl; unicode-bidi: isolate; text-align: left; color: var(--gold-ink);
}
.ar-wrap { display: flex; }
.hero .ar-wrap { justify-content: center; }
.hero .ar { text-align: center; font-size: 1.45em; line-height: 1.6; }

/* ---- Messages ------------------------------------------------------- */
.log { padding: 20px 0 28px; display: flex; flex-direction: column; gap: 22px; }
.msg { animation: rise .22s ease-out both; }
.msg.bot { position: relative; }
.msg.bot .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user {
  align-self: flex-end; max-width: 72%; background: var(--bubble); border-radius: 22px 22px 6px 22px;
  padding: 10px 18px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-actions { display: flex; gap: 4px; margin: 2px 0 -10px -8px; opacity: 0; transition: opacity .15s; }
.msg.bot:hover .msg-actions, .msg.bot.show-actions .msg-actions, .msg-actions:focus-within { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: .4; } }
.msg-actions button {
  border: 0; background: transparent; border-radius: 8px; width: 34px; height: 34px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--muted); cursor: pointer;
}
.msg-actions button:hover { background: var(--chip-hover); color: var(--text); }
.msg-actions svg { width: 18px; height: 18px; }

.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-text); opacity: .35; animation: pulse 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

/* ---- Chips ---------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px; min-height: 44px;
  padding: 9px 17px; cursor: pointer; text-align: left; line-height: 1.35; animation: rise .22s ease-out both;
  transition: border-color .15s, background-color .15s;
}
.chip:hover { border-color: var(--brand); background: var(--brand-tint); }
.chip:disabled { cursor: default; opacity: .4; }
.chip:disabled:hover { border-color: var(--border); background: var(--card); }
.chip.chosen, .chip.chosen:hover { opacity: 1; background: var(--brand-tint); border-color: var(--brand); }
.chip small { display: block; color: var(--muted); font-size: 13px; }

/* ---- Cards ---------------------------------------------------------- */
.card { border: 1px solid var(--border); border-radius: 18px; background: var(--card); padding: 16px; animation: rise .22s ease-out both; }
.member { display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden;
  background: var(--surface); font-family: var(--display); font-size: 20px; color: var(--brand-text);
  position: relative; box-shadow: 0 0 0 1.5px var(--gold);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; opacity: 0; transition: opacity .3s; }
.avatar img.loaded { opacity: 1; }
.member dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.member dt { color: var(--muted); }
.member dd { margin: 0; overflow-wrap: anywhere; }
.member .name { font-weight: 650; }

/* ---- Ticket: an event pass ------------------------------------------ */
.ticket {
  padding: 0; overflow: visible; max-width: 400px; border: 0; background: var(--card); box-shadow: var(--shadow);
  position: relative; animation: flip .7s cubic-bezier(.2, .8, .2, 1) both; transform-origin: top center;
}
.ticket::before { content: ""; position: absolute; inset: 0; border-radius: 18px; border: 1px solid var(--border); pointer-events: none; }
.ticket-head {
  position: relative; overflow: hidden; border-radius: 18px 18px 0 0; padding: 18px 20px 54px; color: #fff;
  background-color: var(--brand);
  background-image: var(--rings), linear-gradient(160deg, rgba(255, 255, 255, .06), rgba(0, 0, 0, .28));
  background-repeat: no-repeat; background-size: 190px 190px, 100% 100%; background-position: right -70px top -70px, 0 0;
  box-shadow: inset 0 -4px 0 var(--gold);
}
.ticket-head .top { display: flex; align-items: center; gap: 10px; }
.ticket-head img { box-sizing: content-box; height: 34px; width: auto; background: #fff; border-radius: 10px; padding: 5px 9px; }
.ticket-head .ev-name { font-family: var(--display); text-transform: uppercase; line-height: .95; margin: 14px 0 14px; }
.ticket-head .ev-name span { display: block; font-size: 30px; }
.ticket-head .ev-name .wm-small { font-size: 22px; }
.ticket-head .ev-name .wm-gold { background: var(--gold-metal); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ticket-head .event-badge { justify-content: flex-start; margin: 0; gap: 10px 16px; }
.ticket-head .eb-day { min-width: 46px; height: 46px; font-size: 24px; border-radius: 10px; }
.ticket-head .eb-when strong { font-size: 14px; }
.ticket-head .eb-when > span, .ticket-head .eb-where strong + span { color: rgba(255, 255, 255, .78); font-size: 12px; }
.ticket-head .eb-where strong { color: #fff; font-size: 15px; }
.ticket-head .eb-where svg { width: 22px; height: 22px; color: #ff6b6f; }
.ticket-medal { position: relative; height: 0; }
.ticket-medal .avatar {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -50%);
  width: 84px; height: 84px; font-size: 30px; background: var(--card);
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 7px var(--card);
}
.ticket-body { padding: 52px 20px 8px; text-align: center; }
.ticket-body .name { font-weight: 800; font-size: 22px; line-height: 1.25; letter-spacing: -.01em; }
.ticket-facts { margin: 14px 0 0; display: grid; text-align: left; }
.ticket-facts div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.ticket-facts dt { color: var(--muted); font-size: 14px; }
.ticket-facts dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.ticket-tear { position: relative; height: 28px; margin: 6px 0; }
.ticket-tear::before {
  content: ""; position: absolute; left: 22px; right: 22px; top: 50%; border-top: 2px dashed var(--border);
}
.ticket-tear .notch {
  position: absolute; top: 50%; width: 28px; height: 28px; border-radius: 50%; transform: translateY(-50%);
  background: var(--bg); box-shadow: inset 0 0 0 1px var(--border);
}
.ticket-tear .notch.l { left: -14px; clip-path: inset(0 0 0 50%); }
.ticket-tear .notch.r { right: -14px; clip-path: inset(0 50% 0 0); }
.ticket-stub { padding: 4px 20px 20px; display: grid; gap: 12px; }
.ticket-qr { background: #fff; border-radius: 14px; padding: 12px; width: 100%; max-width: 240px; margin: 0 auto; box-shadow: 0 0 0 1px var(--border); }
.ticket-qr svg { display: block; width: 100%; height: auto; }
.ticket-code { text-align: center; font-family: var(--display); font-size: 24px; letter-spacing: .03em; color: var(--brand-text); }
.ticket-status { text-align: center; font-weight: 600; font-size: 14px; color: var(--muted); margin-top: -8px; }
.ticket-status.cancelled { color: var(--danger); }
.ticket-status.checked_in { color: var(--ok); }
.ticket-actions { display: grid; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--card); padding: 0 18px; cursor: pointer; font-weight: 600;
  text-decoration: none; color: var(--text); transition: background-color .15s, border-color .15s;
}
.btn.primary { background: var(--btn); color: var(--btn-text); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn:not(.primary):hover { border-color: var(--brand); background: var(--brand-tint); }
.ticket-link { text-align: center; font-size: 14px; }
.ticket-link a { color: var(--muted); }

/* ---- Composer ------------------------------------------------------- */
.dock { padding: 8px 16px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); background: var(--bg); }
.dock .column { padding: 0; }
.composer {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--composer);
  border-radius: 28px; padding: 8px 8px 8px 18px; box-shadow: var(--shadow); min-height: 58px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--brand); box-shadow: var(--shadow), 0 0 0 4px var(--brand-tint); }
.composer.shake { animation: shake .35s; }
.composer[hidden], .dock-hidden .composer, .dock-hidden .hint { display: none; }
.prefix { color: var(--muted); white-space: nowrap; font-size: 15px; user-select: none; padding-right: 8px; border-right: 1px solid var(--border); }
.prefix[hidden] { display: none; }
.composer input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 17px; padding: 6px 0; letter-spacing: .01em;
}
.composer input::placeholder { color: var(--muted); }
.cal[hidden] { display: none; }
.send {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--btn); color: var(--btn-text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
  transition: background-color .15s, transform .15s;
}
.send:not(:disabled):active { transform: scale(.94); }
.send:disabled { background: var(--btn-off); cursor: default; }
.send svg { width: 20px; height: 20px; }
.date-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.hint { min-height: 20px; font-size: 13px; color: var(--danger); text-align: center; margin-top: 4px; }
.disclaimer { font-size: 12px; color: var(--muted); text-align: center; margin: 4px 0 0; }

.to-bottom {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(130px + env(safe-area-inset-bottom));
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--card);
  box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; z-index: 4;
}
.to-bottom[hidden] { display: none; }

/* ---- Plain pages (ticket.php, t.php) ------------------------------- */
.page { max-width: 460px; margin: 0 auto; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); }
.page header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 700; }
.page header img { height: 30px; width: auto; }
.page .ticket { max-width: none; }
.verdict { border-radius: 18px; padding: 18px; text-align: center; font-size: 24px; font-weight: 800; margin-bottom: 16px; }
.verdict.ok { background: rgba(23, 120, 75, .1); color: var(--ok); }
.verdict.bad { background: rgba(179, 38, 30, .1); color: var(--danger); }
.ticket-person { display: flex; gap: 14px; align-items: center; }
.ticket-person .name { font-weight: 800; font-size: 20px; line-height: 1.25; }
.ticket-person .place { color: var(--muted); font-size: 14px; line-height: 1.45; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.85); } 50% { opacity: .9; transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes flip { from { opacity: 0; transform: perspective(900px) rotateX(-60deg) translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 420px) {
  .brand span { display: none; }
}
@media (max-width: 480px) {
  .brand span { font-size: 15.5px; }
  .msg.user { max-width: 85%; }
}
