/* ═══════════════════════════════════════════════════════════════════
   ARIA FLOATING CHAT — v4
   Compact: bottom-right modal (320px)
   Expanded: taller/wider bottom-right modal (480px, near full height)
   Mobile: bottom sheet (portrait) / full screen (landscape)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Suppress old sidebar from style.css ── */
@media (min-width: 1101px) { .aria-sidebar { display: none !important; } }
@media (min-width: 769px) and (max-width: 1100px) { .aria-sidebar { display: none !important; } }

/* ─────────────────────────────────────────────────────────────────
   FLOATING BUBBLE
   ───────────────────────────────────────────────────────────────── */

.aria-bubble {
  position: fixed !important;
  bottom: 2rem;
  right: 1.5rem;
  z-index: 9000;
  display: block !important;
}

.aria-bubble-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(var(--c-pink-rgb), 0.35);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(var(--c-pink-rgb),0.15);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  padding: 0;
  overflow: hidden;
  animation: aria-bubble-pulse 3s ease-in-out infinite;
}

@keyframes aria-bubble-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(var(--c-pink-rgb),0.15); }
  50%       { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 30px rgba(var(--c-pink-rgb),0.3); }
}

.aria-bubble-icon:hover {
  transform: scale(1.12);
  border-color: rgba(var(--c-pink-rgb), 0.6);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 30px rgba(var(--c-pink-rgb),0.35);
}

.aria-bubble-icon:active { transform: scale(0.95); }

/* ─────────────────────────────────────────────────────────────────
   FLOATING CHAT WINDOW — compact (320px bottom-right)
   ───────────────────────────────────────────────────────────────── */

.aria-chat-window {
  position: fixed;
  z-index: 9001;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;

  /* Glass effect */
  background: rgba(10, 10, 18, 0.68);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow:
    0 24px 80px rgba(0,0,0,0.55),
    0 0 40px rgba(var(--c-pink-rgb),0.07),
    inset 0 0 0 1px rgba(255,255,255,0.05),
    inset 0 1px 0 rgba(255,255,255,0.08);

  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.aria-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Desktop compact */
@media (min-width: 769px) {
  .aria-chat-window {
    bottom: 2rem;
    right: 1.5rem;
    width: 320px;
    height: 540px;
    border-radius: 20px;
  }
}

/* Mobile portrait — bottom sheet */
@media (max-width: 768px) {
  .aria-chat-window {
    bottom: 0;
    left: 0;
    right: 0;
    height: 75vh;
    width: 100% !important;
    max-width: 100vw;
    border-radius: 20px 20px 0 0;
  }

  #aria-input { font-size: 16px; }
}

/* Mobile landscape — full screen, input always visible */
@media (max-height: 500px) and (orientation: landscape) {
  .aria-chat-window {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
  }

  .aria-messages {
    max-height: calc(100vh - 130px);
    overflow-y: auto;
  }

  .aria-input-area {
    flex-shrink: 0;
  }
}

/* ─────────────────────────────────────────────────────────────────
   EXPANDED MODE — taller/wider, same position bottom-right
   ───────────────────────────────────────────────────────────────── */

@media (min-width: 769px) {
  .aria-chat-window.aria-expanded {
    bottom: 2rem;
    right: 1.5rem;
    width: 480px !important;
    height: calc(100vh - 4rem) !important;
    border-radius: 20px;
    z-index: 9003;
  }
}

@media (max-width: 768px) {
  .aria-chat-window.aria-expanded {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh !important;
    width: 100% !important;
    border-radius: 0;
    z-index: 9003;
  }
}

/* Larger font in expanded mode */
.aria-chat-window.aria-expanded .aria-message {
  font-size: 0.94rem;
  line-height: 1.65;
}

/* ─────────────────────────────────────────────────────────────────
   CHAT HEADER
   ───────────────────────────────────────────────────────────────── */

.aria-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.aria-chat-header-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: contain;
}

.aria-chat-header-info {
  flex: 1;
  min-width: 0;
}

.aria-chat-header-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.5px;
}

.aria-chat-header-topic {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aria-header-btns {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.aria-chat-close,
.aria-chat-expand {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.aria-chat-close:hover {
  background: rgba(var(--c-orange-rgb), 0.15);
  border-color: rgba(var(--c-orange-rgb), 0.3);
  color: var(--c-orange);
}

.aria-chat-expand:hover {
  background: rgba(var(--c-cyan-rgb), 0.1);
  border-color: rgba(var(--c-cyan-rgb), 0.3);
  color: var(--c-cyan);
}

.aria-chat-expand.is-expanded {
  background: rgba(var(--c-cyan-rgb), 0.1);
  border-color: rgba(var(--c-cyan-rgb), 0.3);
  color: var(--c-cyan);
}

/* ─────────────────────────────────────────────────────────────────
   MESSAGES AREA
   ───────────────────────────────────────────────────────────────── */

.aria-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.aria-messages::-webkit-scrollbar { width: 5px; }
.aria-messages::-webkit-scrollbar-track { background: transparent; }
.aria-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.aria-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.aria-message p {
  margin: 0 0 0.4rem;
  line-height: 1.55;
}
.aria-message p:last-child { margin-bottom: 0; }

.aria-message ul,
.aria-message ol {
  padding-left: 1.2rem;
  margin: 0.2rem 0 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.aria-message li {
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

.aria-message strong { opacity: 0.95; }

.aria-message code {
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-family: 'Source Code Pro', 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 0.82em;
}

.aria-message pre.aria-code-block {
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.4rem 0;
  overflow-x: auto;
  font-size: 0.82em;
  line-height: 1.5;
}

.aria-message pre.aria-code-block code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 1em;
}

.aria-message {
  padding: 0.7rem 1rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
  animation: aria-msg-in 0.25s ease-out;
  max-width: 85%;
}

@keyframes aria-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.aria-message.aria-text {
  background: linear-gradient(135deg, var(--c-pink) 0%, var(--c-pink) 100%);
  color: #ffffff;
  border: none;
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}

.aria-message.user-text {
  background: linear-gradient(135deg, var(--c-purple) 0%, var(--c-purple) 100%);
  color: #ffffff;
  border: none;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

.aria-context-divider {
  text-align: center;
  padding: 0.6rem 0;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0.5rem 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.aria-topic-btn {
  background: linear-gradient(135deg, var(--c-pink), var(--c-pink));
  border: none;
  color: #fff;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0.3rem 0;
  display: inline-block;
  font-family: 'Outfit', sans-serif;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(var(--c-pink-rgb),0.2);
}

.aria-topic-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(var(--c-pink-rgb),0.3);
}

/* ─────────────────────────────────────────────────────────────────
   INPUT AREA
   ───────────────────────────────────────────────────────────────── */

.aria-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

#aria-input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  outline: none;
  transition: 0.2s;
}

#aria-input:focus {
  background: rgba(255,255,255,0.07);
  border-color: var(--c-pink);
  box-shadow: 0 0 10px rgba(var(--c-pink-rgb),0.25);
}

#aria-input::placeholder { color: rgba(255,255,255,0.25); }

#aria-send {
  background: linear-gradient(135deg, var(--c-pink), var(--c-pink));
  border: none;
  color: #fff;
  padding: 0.6rem 1.1rem;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(var(--c-pink-rgb),0.2);
}

#aria-send:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(var(--c-pink-rgb),0.35);
}

#aria-send:active:not(:disabled) { transform: translateY(0); }
#aria-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─────────────────────────────────────────────────────────────────
   TEXT SELECTION PILL
   ───────────────────────────────────────────────────────────────── */

.aria-selection-pill {
  position: fixed;
  z-index: 9500;
  background: linear-gradient(135deg, var(--c-pink), var(--c-pink));
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(var(--c-pink-rgb),0.35);
  display: none;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
  pointer-events: auto;
}

.aria-selection-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--c-pink-rgb),0.5);
}

.aria-selection-pill.visible { display: flex; }

/* ─────────────────────────────────────────────────────────────────
   EXAM MODE
   ───────────────────────────────────────────────────────────────── */

body.exam-mode #aria-bubble,
body.exam-mode #aria-chat-window,
body.exam-mode .aria-selection-pill {
  display: none !important;
}

/* ─────────────────────────────────────────────────────────────────
   MOBILE — Hide hero images, show topic title
   ───────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {

  .content-block img {
    display: none;
  }

  .content-container h1 {
    display: block !important;
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    padding-top: 0.5rem;
  }

}

/* ═════════════════════════════════════════════════════════════════
   THE 'a' MARK
   The same treatment as the notebook wordmark: the letter is a MASK,
   and what shows through it is the brand gradient, drifting slowly.
   So the mark is painted from palette.css rather than baked into a
   PNG — change a brand colour and every 'a' on every tool follows.

   Lives here because aria-chat.css is the one stylesheet all five
   tools share, and a mask url() resolves against the stylesheet, not
   the page — so this one rule works from any folder depth.

   Use: <span class="aria-mark" role="img" aria-label="aria"></span>
   ═════════════════════════════════════════════════════════════════ */
.aria-mark {
  display: block;
  /* No width or height here on purpose. The mark is dropped into boxes of
     very different sizes — a 64px bubble, a 60px header logo, a 30px one —
     so each place says how big it is and the square aspect keeps it from
     stretching. Setting 100% here made it fill whatever it landed in and
     shove the wordmark beside it onto two lines. */
  aspect-ratio: 1 / 1;
  background: linear-gradient(120deg,
    rgba(var(--c-pink-rgb), 0.95) 0%,
    rgba(var(--c-purple-rgb), 0.95) 24%,
    rgba(var(--c-blue-new-rgb), 0.95) 44%,
    rgba(var(--c-cyan-rgb), 0.95) 62%,
    rgba(var(--c-gold-rgb), 0.92) 80%,
    rgba(var(--c-orange-rgb), 0.95) 100%
  );
  /* Only a little wider than the letter. The wordmark can be 160% because
     it is five letters long and the whole palette lands across it; one
     letter at 260% only ever shows a slice, so it read as the old pink-to-
     purple PNG. At 130% every colour is on the letter at once and the
     drift moves them through it. */
  background-size: 130% 100%;
  background-repeat: no-repeat;
  -webkit-mask: url('aria-a.png') center / contain no-repeat;
          mask: url('aria-a.png') center / contain no-repeat;
  animation: aria-mark-drift 18s ease-in-out infinite alternate;
}

/* the floating bubble is the one place the mark should fill its box */
.aria-bubble-icon .aria-mark { width: 100%; height: 100%; }
/* the header mark takes its height from the tool's own .logo-img rule */
.aria-mark.logo-img { height: 60px; width: 60px; }

@keyframes aria-mark-drift {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* No masking support: fall back to the flat letter rather than a
   gradient-coloured rectangle. */
@supports not ((-webkit-mask: url('#')) or (mask: url('#'))) {
  .aria-mark {
    background: url('aria-a.png') center / contain no-repeat;
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aria-mark { animation: none; }
}
