/*
  rolandvideochat
  Copyright (c) 2026 rolandvideochat. All rights reserved.
*/

:root {
  --page: #050505;
  --surface: #111111;
  --surface-muted: #1a1113;
  --border: #3b2025;
  --text: #f5f1f2;
  --muted: #b5a7aa;
  --muted-light: #806e72;
  --accent: #7d1f2c;
  --accent-hover: #982b3a;
  --accent-soft: #32151a;
  --success: #5dbb82;
  --danger: #a93645;
  --radius: 6px;
  --content-width: 720px;
  --header-height: 64px;
  --controls-height: 76px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--text);
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(23, 105, 170, .25); outline-offset: 2px; }
input { min-width: 0; }
h1, .brand { font-family: 'Sora', 'Inter', Arial, sans-serif; }
.mono { font-family: 'JetBrains Mono', 'Courier New', monospace !important; }
::selection { background: var(--accent); color: #fff; }
#app { width: 100%; height: 100%; position: relative; }

.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 18px; font-weight: 700; }
.brand.small { font-size: 15px; }
.brand .mark { width: 20px; height: 20px; flex: none; border: 2px solid var(--accent-hover); border-radius: 4px; background: var(--accent); }

.pill-btn { min-height: 40px; text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 16px; background: var(--surface); color: var(--text); font-size: 14px; font-weight: 700; }
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.pill-btn:disabled { cursor: not-allowed; opacity: .55; }
.pill-btn.block { width: 100%; }
.pill-btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.pill-btn.primary:hover { background: var(--accent-hover); color: #fff; }

.online-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; background: var(--surface); color: var(--muted); font-size: 12px; white-space: nowrap; }
.online-chip i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--success); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.directory-link { display: inline-flex; align-items: center; min-height: 30px; border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; background: var(--accent-soft); color: var(--text); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.directory-link::before { width: 6px; height: 6px; margin-right: 7px; border: 1px solid var(--accent-hover); border-radius: 50%; background: var(--accent); content: ''; }
.directory-link:hover { border-color: var(--accent-hover); background: var(--accent); color: #fff; }
.directory-link:focus-visible { outline: 3px solid rgba(152, 43, 58, .35); outline-offset: 2px; }

#landing { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 20px; overflow-x: hidden; overflow-y: auto; padding: clamp(78px, 12vh, 112px) 16px 24px; }
#landing .top-row { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-copy { width: 100%; max-width: var(--content-width); text-align: center; }
.hero-copy h1 { margin: 0 0 10px; font-size: clamp(26px, 5vw, 42px); line-height: 1.12; }
.hero-copy h1 span { color: var(--accent); }
.hero-copy p { max-width: 560px; margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.55; }
.auth-card { width: min(100%, 420px); flex: 0 0 auto; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card-stripe { height: 5px; background: var(--accent); }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab { flex: 1; border: 0; border-bottom: 3px solid transparent; padding: 13px 8px 11px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.tab.active { border-bottom-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.tab-body { padding: 20px; }
.tab-panel { display: none; flex-direction: column; gap: 14px; }
.tab-panel.active { display: flex; }
.room-visibility { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-muted); cursor: pointer; }
.room-visibility > span:first-child { display: flex; flex-direction: column; gap: 3px; }
.room-visibility strong { color: var(--text); font-size: 13px; }
.room-visibility small { color: var(--muted); font-size: 11px; }
.room-visibility input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { position: relative; width: 40px; height: 22px; flex: none; border-radius: 999px; background: var(--muted-light); transition: background .2s ease; }
.toggle-track::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; content: ''; transition: transform .2s ease; }
.room-visibility input:checked + .toggle-track { background: var(--accent); }
.room-visibility input:checked + .toggle-track::after { transform: translateX(18px); }
.public-room-fields { display: flex; flex-direction: column; gap: 7px; }
.public-room-fields[hidden] { display: none; }
.public-room-fields textarea { width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.public-room-fields textarea:focus { border-color: var(--accent); outline: 0; }
.tab-intro { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.field-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.code-input { width: 100%; margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); color: var(--text); font-family: 'Courier New', monospace; font-size: 20px; font-weight: 700; letter-spacing: .2em; text-align: center; text-transform: uppercase; }
.code-input:focus, .chat-input-row input:focus { border-color: var(--accent); outline: 0; }
.field-hint, .cam-note, .copyright-note { color: var(--muted-light); font-size: 12px; }
.field-hint { margin-top: 7px; }
.form-error { display: none; color: var(--danger); font-size: 13px; }
.form-error.show { display: block; }
.cam-note, .copyright-note { text-align: center; }
.copyright-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; width: 100%; }
.footer-links { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent-hover); text-decoration: underline; }
.guidelines { width: 100%; max-width: 560px; border-top: 1px solid var(--border); padding-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.guidelines b { color: var(--text); }

#meetingScreen { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--page); }
.chat-header { z-index: 5; display: flex; align-items: center; gap: 12px; min-height: var(--header-height); border-bottom: 1px solid var(--border); padding: 10px 16px; background: var(--surface); }
.chat-header .right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.status-text { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status-text.live { color: var(--success); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-light); }
.status-text.live .status-dot { background: var(--success); }
.room-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 6px 5px 12px; background: var(--surface-muted); color: var(--muted); font-size: 13px; }
.room-chip .mono { color: var(--text); font-weight: 700; letter-spacing: .12em; }
.room-chip button { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--accent); }
.room-chip button svg { width: 14px; height: 14px; }

.stage { position: relative; display: flex; flex: 1; min-height: 0; overflow: hidden; }
.video-area { position: relative; min-width: 0; flex: 1; overflow: hidden; padding: 12px; }
.tile-grid { display: grid; width: 100%; height: 100%; gap: 12px; grid-auto-rows: 1fr; grid-template-columns: repeat(2, 1fr); }
.tile-grid.n1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.tile-grid.n2 { grid-template-rows: 1fr; }
.tile-grid.n3, .tile-grid.n4 { grid-template-rows: repeat(2, 1fr); }
.tile-grid.n3 .tile:first-child { grid-column: 1 / span 2; }
.tile { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #000; }
.tile.camera-off::after { content: 'Camera off'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .72); color: var(--muted-light); font-size: 13px; font-weight: 700; }
.tile video { display: block; width: 100%; height: 100%; background: #000; object-fit: contain; }
.tile.local video { transform: scaleX(-1); }
.tile .tile-label { position: absolute; bottom: 8px; left: 8px; z-index: 1; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 16px); border: 1px solid var(--accent-hover); border-radius: 4px; padding: 5px 8px; background: rgba(38, 12, 16, .92); color: var(--text); font-size: 12px; font-weight: 700; }
.tile .tile-label .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .tile-label .mic-off { display: none; color: var(--danger); }
.tile .tile-label.is-muted .mic-off { display: inline-flex; }
.waiting-banner { position: absolute; top: 20px; left: 50%; z-index: 3; display: flex; align-items: center; gap: 8px; max-width: calc(100% - 40px); transform: translateX(-50%); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; background: var(--surface); color: var(--muted); font-size: 12px; text-align: center; }
.waiting-banner span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.waiting-banner .spin { width: 12px; height: 12px; flex: none; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chat-panel { display: flex; flex: 0 0 320px; flex-direction: column; border-left: 1px solid var(--border); background: var(--surface); transition: margin-right .2s ease; }
.chat-panel.collapsed { margin-right: -320px; }
.chat-panel-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 14px 16px; color: var(--muted); font-size: 13px; font-weight: 700; }
#chatPanelClose { cursor: pointer; color: var(--muted); }
.chat-messages { display: flex; flex: 1; flex-direction: column; gap: 10px; overflow-y: auto; padding: 14px 16px; }
.msg { max-width: 88%; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 11px; color: var(--text); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.msg .msg-from { margin-bottom: 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
.msg.me { align-self: flex-end; border-color: var(--accent); background: var(--accent-soft); }
.msg.them { align-self: flex-start; background: var(--surface-muted); }
.msg.sys { align-self: center; border: 0; padding: 2px; background: transparent; color: var(--muted-light); font-size: 12px; text-align: center; }
.chat-input-row { display: flex; gap: 8px; border-top: 1px solid var(--border); padding: 12px; }
.chat-input-row input { flex: 1; min-height: 38px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); color: var(--text); font-size: 13px; }
.chat-input-row button { width: 38px; height: 38px; flex: none; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: #fff; font-size: 18px; }

.controls { display: flex; align-items: center; justify-content: center; flex: none; gap: 10px; min-height: var(--controls-height); border-top: 1px solid var(--border); padding: 12px 16px; background: var(--surface); }
.icon-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.off, .icon-btn.leave { border-color: var(--danger); background: var(--danger); color: #fff; }
.icon-btn.leave { width: auto; font-weight: 700; }

@media (max-width: 760px) {
  #landing { gap: 18px; padding-right: 12px; padding-left: 12px; }
  #landing .top-row { align-items: flex-start; }
  .brand { font-size: 16px; }
  .hero-copy h1 { font-size: clamp(25px, 8vw, 36px); }
  .chat-header { flex-wrap: wrap; padding: 8px 12px; }
  .chat-header .status-text { order: 3; width: 100%; }
  .chat-header .right { margin-left: auto; }
  .room-chip { order: 4; width: 100%; justify-content: center; }
  .chat-panel { position: absolute; inset: 0 0 0 auto; z-index: 4; width: min(100%, 340px); flex-basis: auto; box-shadow: -8px 0 20px rgba(23, 32, 42, .12); }
  .chat-panel.collapsed { margin-right: -100%; }
  .video-area { padding: 8px; }
  .tile-grid.n2, .tile-grid.n3, .tile-grid.n4 { grid-template-columns: 1fr; grid-template-rows: repeat(auto-fit, minmax(0, 1fr)); }
  .tile-grid.n3 .tile:first-child { grid-column: auto; }
  .controls { gap: 8px; padding: 10px 12px; }
}

@media (min-height: 720px) and (min-width: 761px) {
  #landing { justify-content: center; }
}

@media (max-width: 380px) {
  #landing .top-row { left: 10px; right: 10px; }
  .top-actions { gap: 5px; }
  .directory-link { padding-right: 8px; padding-left: 8px; }
  .directory-link::before { margin-right: 5px; }
  .online-chip { padding-right: 7px; padding-left: 7px; }
  .guidelines { font-size: 11px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn.leave { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Public room directory */
.public-directory { width: min(100% - 32px, 900px); min-height: 100%; margin: 0 auto; overflow-y: auto; padding: 24px 0 48px; }
.directory-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); padding-bottom: 18px; }
.directory-header a { text-decoration: none; }
.directory-intro { max-width: 650px; padding: 64px 0 28px; }
.eyebrow { margin: 0 0 10px; color: var(--accent-hover); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.directory-intro h1 { margin: 0 0 10px; color: var(--text); font-size: clamp(28px, 6vw, 48px); }
.directory-intro > p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); line-height: 1.6; }
.directory-search { width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); color: var(--text); font-size: 14px; }
.directory-search:focus { border-color: var(--accent); outline: 0; }
.room-list { display: grid; gap: 12px; }
.directory-status { margin: 0; border: 1px dashed var(--border); padding: 24px; color: var(--muted); text-align: center; }
.public-room-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: var(--surface); }
.public-room-content { min-width: 0; }
.public-room-card h2 { margin: 0 0 8px; color: var(--text); font-family: 'Sora', 'Inter', Arial, sans-serif; font-size: 16px; overflow-wrap: anywhere; }
.room-occupancy { margin: 0; color: var(--success); font-size: 12px; font-weight: 700; }
.public-room-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.public-room-actions code { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--surface-muted); color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 13px; letter-spacing: .08em; }
.room-action { min-height: 40px; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; }
.room-action:hover { border-color: var(--accent); color: var(--accent-hover); }

@media (max-width: 600px) {
  .public-directory { width: min(100% - 24px, 900px); padding-top: 16px; }
  .directory-header { align-items: flex-start; }
  .directory-header .pill-btn { padding-right: 10px; padding-left: 10px; font-size: 12px; }
  .directory-intro { padding-top: 40px; }
  .public-room-card { align-items: stretch; flex-direction: column; gap: 14px; }
  .public-room-actions { flex-wrap: wrap; }
  .public-room-actions code { flex: 1; text-align: center; }
}
