/* ==========================================================================
   Daine Tutoring — site assistant widget
   Uses the shared design tokens from college-theme.css.
   ========================================================================== */

.dt-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Launcher ----------------------------------------------------------- */

.dt-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px 13px 16px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--navy);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(11, 21, 48, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.dt-chat-launcher:hover {
  background: var(--navy-dark);
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(11, 21, 48, 0.34);
}

.dt-chat-launcher:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}

.dt-chat-launcher-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  color: var(--gold-light);
}

.dt-chat-launcher-icon svg { width: 100%; height: 100%; }

.dt-chat-launcher[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
}

/* --- Panel -------------------------------------------------------------- */

.dt-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 121;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 26px 70px rgba(11, 21, 48, 0.3);
  overflow: hidden;
}

.dt-chat-panel[hidden] { display: none; }

.dt-chat-panel.is-opening {
  animation: dtChatIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dtChatIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* --- Header ------------------------------------------------------------- */

.dt-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  background: var(--navy);
  color: var(--white);
}

.dt-chat-header-mark {
  flex: none;
  display: block;
  width: 38px;
  height: 38px;
}

.dt-chat-header-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dt-chat-header-text { flex: 1; min-width: 0; }

.dt-chat-header-text h2 {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--white);
}

.dt-chat-header-text p {
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.64);
}

.dt-chat-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.dt-chat-close svg { width: 17px; height: 17px; }
.dt-chat-close:hover { background: rgba(255, 255, 255, 0.1); color: var(--white); }
.dt-chat-close:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

/* --- Log ---------------------------------------------------------------- */

.dt-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(19, 32, 72, 0.22) transparent;
}

.dt-chat-log::-webkit-scrollbar { width: 8px; }
.dt-chat-log::-webkit-scrollbar-thumb {
  background: rgba(19, 32, 72, 0.18);
  border-radius: 4px;
}

.dt-chat-msg {
  max-width: 86%;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.55;
  border-radius: var(--radius);
}

.dt-chat-msg p + p { margin-top: 8px; }

.dt-chat-msg-bot p,
.dt-chat-msg-bot { color: var(--ink); }

.dt-chat-msg-user p,
.dt-chat-msg-user { color: var(--cream); }

.dt-chat-msg-error p,
.dt-chat-msg-error { color: var(--ink-soft); }

.dt-chat-msg a {
  color: inherit;
  font-weight: 600;
  text-underline-offset: 2px;
}

.dt-chat-msg-bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  color: var(--ink);
}

.dt-chat-msg-user {
  align-self: flex-end;
  background: var(--navy);
  border-bottom-right-radius: 5px;
  color: var(--cream);
}

.dt-chat-msg-error {
  align-self: flex-start;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.86rem;
}

/* Typing indicator */
.dt-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 15px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-bottom-left-radius: 5px;
}

.dt-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(19, 32, 72, 0.32);
  animation: dtChatBlink 1.3s infinite ease-in-out;
}

.dt-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.dt-chat-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes dtChatBlink {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}

/* --- Suggested questions ------------------------------------------------ */

.dt-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.dt-chat-suggestions button {
  padding: 8px 13px;
  border: 1px solid rgba(19, 32, 72, 0.18);
  border-radius: 999px;
  background: transparent;
  color: var(--navy);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.dt-chat-suggestions button:hover {
  background: var(--paper);
  border-color: var(--gold);
}

.dt-chat-suggestions button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* --- Composer ----------------------------------------------------------- */

.dt-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  border-top: 1px solid var(--line);
  background: var(--cream);
}

.dt-chat-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid rgba(19, 32, 72, 0.16);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.dt-chat-form input::placeholder { color: rgba(28, 36, 54, 0.45); }

.dt-chat-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.16);
}

.dt-chat-form button {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.dt-chat-form button svg { width: 19px; height: 19px; }
.dt-chat-form button:hover:not(:disabled) { background: var(--gold-light); }
.dt-chat-form button:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.dt-chat-form button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dt-chat-disclosure {
  padding: 0 16px 12px;
  background: var(--cream);
  font-family: var(--font-body);
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: center;
}

/* --- Mobile ------------------------------------------------------------- */

@media (max-width: 720px) {
  .dt-chat-launcher {
    right: 16px;
    bottom: 16px;
    padding: 11px 17px 11px 14px;
    font-size: 0.88rem;
  }

  .dt-chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: none;
    border-radius: 0;
  }

  body.dt-chat-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .dt-chat-launcher,
  .dt-chat-panel,
  .dt-chat-typing span {
    transition: none;
    animation: none;
  }
}

/* --- Start gate (name + email) ------------------------------------------- */

.dt-chat-gate {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  background: var(--cream);
}

.dt-chat-gate h3 {
  font-family: var(--font-display);
  font-size: 1.16rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--navy);
}

.dt-chat-gate > p {
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.dt-chat-gate-field { margin-top: 16px; }

.dt-chat-gate-field label {
  display: block;
  margin-bottom: 5px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--navy);
}

.dt-chat-gate-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(19, 32, 72, 0.18);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.dt-chat-gate-field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.16);
}

.dt-chat-gate-field input[aria-invalid="true"] {
  border-color: #a8324a;
}

.dt-chat-gate-error {
  margin-top: 6px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: #a8324a;
}

.dt-chat-gate-error[hidden] { display: none; }

.dt-chat-gate-consent {
  display: flex;
  gap: 9px;
  margin-top: 18px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.dt-chat-gate-consent input {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--navy);
}

.dt-chat-gate-submit {
  width: 100%;
  margin-top: 20px;
  padding: 13px 18px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy);
  font-family: var(--font-body);
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease;
}

.dt-chat-gate-submit:hover { background: var(--gold-light); }
.dt-chat-gate-submit:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.dt-chat-gate-skip {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 4px;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.dt-chat-gate-skip:hover { color: var(--navy); }

.dt-chat-log[hidden],
.dt-chat-form[hidden],
.dt-chat-gate[hidden] { display: none !important; }
