/* Google-search–style chat page. Loaded after style.css (admin keeps style.css only). */
:root {
  --g-blue: #4285f4;
  --g-red: #ea4335;
  --g-yellow: #fbbc05;
  --g-green: #34a853;
  /* Dariali Energy brand guidelines, secondary colours 1–4 (pp. 33–36): logo and quiz icon */
  --d-red: #ee4023;
  --d-teal: #3cb994;
  --d-lime: #e1e319;
  --d-green: #004b23;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #202124;
  --muted: #70757a;
  --border: #dfe1e5;
  --pill: #f1f3f4;
  --shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  --accent: #1c3d5c; /* Dariali Energy Primary Blue (guidelines p. 31) */
  font-family: 'Google Sans', 'Product Sans', 'Segoe UI', Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --surface: #303134;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #5f6368;
    --pill: #303134;
    --shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
    --accent: #9cc0e4; /* light tint of the brand blue for dark pages */
  }
}

body { background: var(--bg); color: var(--text); }

/* ---------- logo ---------- */
/* Saira Stencil One (SIL OFL), subset to the letters A, S, K only */
@font-face {
  font-family: 'ASK Stencil';
  src: url('/fonts/saira-stencil-ask.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+41, U+4B, U+53;
}
.logo {
  font-family: 'ASK Stencil', system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1;
  user-select: none;
  margin: 0;
}
.logo .a { color: var(--d-teal); }
.logo .s { color: var(--d-red); }
.logo .k { color: var(--d-lime); }
.logo.big { font-size: clamp(72px, 18vw, 120px); }
.logo.small { font-size: 30px; text-decoration: none; }

/* ---------- layout ---------- */
.shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 10px;
}
.top button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
  color: var(--text);
}
.top button:hover { background: var(--pill); }

.hero { text-align: center; }
.hero p { color: var(--muted); margin: 14px 0 26px; font-size: 15px; }

/* ---------- search box (the one window) ---------- */
.searchbox {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 5px 6px 5px 16px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.searchbox:hover,
.searchbox:focus-within { box-shadow: var(--shadow); border-color: transparent; }
.searchbox .icon { flex: none; width: 20px; height: 20px; margin-bottom: 9px; color: var(--muted); }
.searchbox textarea {
  flex: 1;
  border: 0;
  background: transparent;
  resize: none;
  padding: 8px 4px;
  min-height: 38px;
  max-height: 160px;
  font-size: 16px;
  line-height: 1.4;
}
.searchbox textarea:focus { outline: none; }
.searchbox button {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--accent);
}
.searchbox button:hover:not(:disabled) { background: var(--pill); }
.searchbox button svg { width: 22px; height: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }
.chips button {
  background: var(--pill);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text);
}
.chips button:hover { border-color: var(--border); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); }

.note { text-align: center; font-size: 12px; color: var(--muted); padding: 10px 0 14px; }

/* ---------- results (Google-style: newest question on top) ---------- */
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.assistant { background: none; border: 0; padding: 0; border-radius: 0; }
#messages { display: flex; flex-direction: column; gap: 28px; }
.result .query { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.result .query::before { content: '🔍 '; }
.result.current .query { font-size: 13px; }
.earlier {
  color: var(--muted); font-size: 13px; text-transform: none;
  border-top: 1px solid var(--border); padding-top: 18px; margin-top: 4px;
}
.result:not(.current) { opacity: 0.85; }

/* ---------- two states: home (empty) and chatting ---------- */
body.home .shell { justify-content: center; padding-bottom: 12vh; }
body.home .top,
body.home #messages { display: none; }
body.chatting .hero,
body.chatting .chips { display: none; }

/* chatting = results page: full-width top bar with logo + search box, answers below */
body.chatting .shell { --lead: 110px; max-width: none; height: auto; min-height: 100%; padding: 0; }
body.chatting .top {
  position: sticky; top: 0; z-index: 5;
  justify-content: flex-start; gap: 24px;
  padding: 18px 24px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
body.chatting .top .logo.small { flex: none; width: calc(var(--lead) - 24px - 24px); }
.top-search { flex: 1; min-width: 0; max-width: 690px; }
body.chatting .top #new-chat { margin-left: auto; flex: none; }
body.chatting .searchbox { box-shadow: var(--shadow); border-color: transparent; }
body.chatting #messages {
  max-width: calc(var(--lead) + 652px);
  padding: 22px 24px 32px var(--lead);
}
body.chatting .note { text-align: left; padding: 10px 24px 18px var(--lead); max-width: calc(var(--lead) + 652px); }

@media (max-width: 720px) {
  body.chatting .top { flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px; }
  body.chatting .top .logo.small { width: auto; }
  .top-search { order: 3; flex-basis: 100%; max-width: none; }
  body.chatting #messages,
  body.chatting .note { padding-left: 16px; padding-right: 16px; }
}

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form {
  width: 100%; max-width: 420px; display: grid; gap: 14px; text-align: center;
  background: none; border: 0; padding: 0;
}
.login input { border-radius: 24px; padding: 12px 18px; border: 1px solid var(--border); background: var(--surface); }
.login button.primary { justify-self: center; border-radius: 6px; background: var(--pill); color: var(--text); border: 1px solid transparent; padding: 9px 22px; }

/* links and the "searching the web" notice */
.msg.assistant a { color: var(--accent); text-decoration: none; }
.msg.assistant a:hover { text-decoration: underline; }
.msg.assistant .notice { color: var(--muted); }

/* ---------- protected material (email-code authorization) ---------- */
.secure-panel {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--d-teal);
  border-radius: 12px;
  background: var(--surface);
}
.secure-panel p { margin: 0 0 10px; }
.secure-panel .row { display: flex; gap: 8px; flex-wrap: wrap; }
.secure-panel input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.secure-panel .error { margin-top: 8px; }
.secure-panel .timer { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.secure-panel .timer.low { color: var(--d-red); }
.secure-panel .link {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}
.secure-panel .chips { justify-content: flex-start; margin: 0; }
.secure-panel .chips button.on { border-color: var(--accent); color: var(--accent); }
.secure-detail:not(:empty) { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
body.chatting .secure-panel .chips { display: flex; }

/* Error / refusal messages: full-contrast text on a brand-red tinted box (red text alone was unreadable) */
:root { --error-bg: #fde8e4; }
@media (prefers-color-scheme: dark) { :root { --error-bg: #4a2620; } }
.error:not(:empty) {
  color: var(--text); background: var(--error-bg);
  border-left: 4px solid var(--d-red); border-radius: 8px;
  padding: 8px 12px; font-size: 14px; font-weight: 500; line-height: 1.45;
}
