/* ==========================================================================
   home.css — the main page greeting, the domain suggestions, and the
   transition that carries you from here into a domain.

   Loaded only by chat.ejs. Same rules as the rest of the app: flat surfaces,
   1px borders, no shadow, no glow, palette from what is already in style.css.
   ========================================================================== */

:root {
  --hm-red: #ac3736;
  --hm-red-deep: #79070e;
  --hm-ink: #2b2523;
  --hm-muted: #6b5c57;
  --hm-line: #e8ddcc;
  --hm-surface: #ffffff;
  --hm-ease: cubic-bezier(.22, .68, .36, 1);
  /* One number for the whole hand-off, shared by the page leaving here and
     the page arriving there. Changing it in one place changes both. */
  --hm-exit: 420ms;
}

/* ── Greeting ──────────────────────────────────────────────────────────── */

/* The generated greeting replaces the fixed one in place. Crossfading the
   text rather than swapping it stops the page from flickering between two
   different sentences a beat apart. */
.welcome-title {
  transition: opacity .28s ease, transform .28s var(--hm-ease);
}

.welcome-container.is-swapping .welcome-title,
.welcome-container.is-swapping .welcome-line {
  opacity: 0;
  transform: translateY(-6px);
}

.welcome-line {
  max-width: 520px;
  margin: 0 auto;
  color: var(--hm-muted);
  font-size: 15px;
  line-height: 1.7;
  opacity: 1;
  transition: opacity .28s ease, transform .28s var(--hm-ease);
}

.welcome-line[hidden] { display: none; }

/* ── Suggestions ───────────────────────────────────────────────────────── */

.welcome-suggest {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 22px;
}

.welcome-suggest[hidden] { display: none; }

/* Flat pill, like every other chip in the app. */
.suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 17px;
  border-radius: 999px;
  border: 1px solid var(--hm-line);
  background: var(--hm-surface);
  color: var(--hm-ink);
  font-family: inherit;
  font-size: 13.5px;
  /* style.css sets `height: 100%` on every button. */
  height: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  animation: hmChipIn .34s var(--hm-ease) forwards;
  transition: background-color .18s ease, color .18s ease,
              border-color .18s ease, transform .18s ease;
}

@keyframes hmChipIn {
  to { opacity: 1; transform: translateY(0); }
}

.suggest-chip:nth-child(2) { animation-delay: .07s; }

.suggest-chip i { font-size: 12px; color: var(--hm-red); transition: color .18s ease; }

.suggest-chip:hover {
  background: var(--hm-red);
  border-color: var(--hm-red);
  color: #fff;
  transform: translateY(-1px);
}

.suggest-chip:hover i { color: #fff; }
.suggest-chip:active { transform: translateY(0); }

/* A chip that has been chosen holds the pressed state for the whole exit,
   so the thing you clicked stays lit while the page leaves. */
.suggest-chip.is-chosen {
  background: var(--hm-red-deep);
  border-color: var(--hm-red-deep);
  color: #fff;
}

.suggest-chip.is-chosen i { color: #fff; }

/* ── The "+" panel: «شنوة تحب تعمل؟» (brand: docs/brand.md) ───────────────
   Same anatomy as the tourism panel: a title, then each option with a
   one-colour icon, its name and one line saying what it does. A sheet from
   the bottom on phones. */
.chat-input #uploadButton[hidden] { display: none !important; }
.chat-input .tools-btn.ix-more[aria-expanded="true"] { background: var(--hm-red); color: #fff; }

.tools-dropdown.ix-panel {
  flex-direction: column; gap: 6px;
  width: min(380px, calc(100vw - 32px)); min-width: 0; max-height: min(70vh, 560px); overflow-y: auto;
  margin-bottom: 10px; padding: 12px; border: 1px solid var(--hm-line); border-radius: 22px;
  background: #f8f2e8; box-shadow: 0 18px 44px rgba(43, 37, 35, .2); scrollbar-width: none;
  text-align: start; animation: ix-panel-in .22s var(--hm-ease);
}
.tools-dropdown.ix-panel::-webkit-scrollbar { display: none; }
.ix-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 4px; }
.ix-panel-head strong { font-size: 16px; font-weight: 700; color: var(--hm-ink); }
.ix-panel-close {
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--hm-surface); color: var(--hm-muted); font: inherit; cursor: pointer;
}
.ix-panel .tools-dropdown-item.ix-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px;
  padding: 9px 11px; border: 1px solid var(--hm-line); border-radius: 16px; background: var(--hm-surface);
  color: var(--hm-ink); font: inherit; font-weight: 400; text-align: start; cursor: pointer;
  transition: border-color .18s ease, transform .18s ease;
}
.ix-panel .tools-dropdown-item.ix-item:hover { background: var(--hm-surface); color: var(--hm-ink); border-color: var(--hm-red); }
.ix-panel .tools-dropdown-item.ix-item:active { transform: scale(.98); }
.ix-panel .tools-dropdown-item.ix-item:focus-visible, .ix-panel-close:focus-visible { outline: 2px solid var(--hm-red); outline-offset: 2px; }
.ix-item-icon {
  flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--hm-line); background: #f8f2e8; color: var(--hm-ink); font-size: 17px;
}
.ix-panel .tools-dropdown-item.ix-item i { width: 1.2em; font-size: inherit; text-align: initial; }
.ix-item-text { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
.ix-item-text strong { font-size: 14px; font-weight: 700; line-height: 1.35; }
.ix-item-text small { font-size: 12px; line-height: 1.5; color: var(--hm-muted); }
/* Google search is on: said in words, and the item is outlined. */
.ix-item-on { display: none; flex: 0 0 auto; padding: 2px 8px; border-radius: 999px; background: var(--hm-red); color: #fff; font-size: 10.5px; font-style: normal; font-weight: 700; }
.ix-panel .tools-dropdown-item.ix-item.active { background: var(--hm-surface); color: var(--hm-ink); border-color: var(--hm-red); }
.ix-panel .tools-dropdown-item.ix-item.active .ix-item-on { display: inline-block; }

.tools-dd-heading { padding: 8px 6px 2px; font-size: 12px; font-weight: 700; color: var(--hm-muted); }

/* Not shipped yet: readable, clearly inert. */
.ix-panel .tools-dropdown-item.ix-item.is-soon { cursor: default; border-style: dashed; background: transparent; }
.ix-panel .tools-dropdown-item.ix-item.is-soon:hover { border-color: var(--hm-line); background: transparent; color: var(--hm-ink); }
.ix-panel .tools-dropdown-item.ix-item.is-soon .ix-item-icon,
.ix-panel .tools-dropdown-item.ix-item.is-soon .ix-item-text { opacity: .6; }
.domain-soon {
  flex: 0 0 auto; padding: 2px 8px; border: 1px solid var(--hm-line); border-radius: 999px;
  font-size: 10.5px; line-height: 1.6; color: var(--hm-muted); white-space: nowrap;
}
@keyframes ix-panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ix-sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* The search mode pill next to the "+". */
.chat-input .active-tool-label { border-color: var(--hm-line); color: var(--hm-ink); background: var(--hm-surface); }

@media (max-width: 640px) {
  .tools-dropdown.ix-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 2000; width: auto;
    height: 60vh; max-height: 60vh; margin: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px)); border-radius: 24px 24px 0 0; border-bottom: 0;
    box-shadow: 0 -12px 40px rgba(43, 37, 35, .18);
    animation: ix-sheet-up .28s var(--hm-ease);
  }
}
@media (prefers-reduced-motion: reduce) { .tools-dropdown.ix-panel { animation: none; } }

/* ── Composer morph ────────────────────────────────────────────────────── */

/* On the way into a domain the composer becomes that domain's composer before
   the page even turns over: the upload and tools buttons fold away, the
   placeholder changes, and the whole field gets shorter. Doing it here rather
   than on arrival means the two composers line up across the cut instead of
   jumping.

   `max-width` does the folding — width:0 on a flex item with content still
   leaves it laying out, and `display:none` would snap instead of collapse. */
.chat-input .tools-left {
  max-width: 200px;
  transition: max-width .34s var(--hm-ease), opacity .24s ease, transform .3s var(--hm-ease);
}

/* `overflow: hidden` belongs ONLY here, never on the resting .tools-left.

   .tools-left is the positioning parent of .tools-dropdown, and the dropdown
   opens upward — entirely outside .tools-left's own 36px box. Clipping it at
   rest silently swallowed the whole tools menu: it still opened, still had
   z-index 1000, but it was painted nowhere, so every click fell straight
   through to the textarea behind it. While morphing there is no open menu to
   clip, so the clipping is safe here and only here. */
.chat-input.is-morphing .tools-left {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transform: scale(.82);
  pointer-events: none;
}

/* The preview strip goes too, and takes its height with it. */
.chat-input .image-preview-container {
  transition: opacity .2s ease, transform .24s var(--hm-ease);
}

.chat-input.is-morphing .image-preview-container {
  opacity: 0;
  transform: scale(.9);
}

.chat-input .input-container,
.chat-input .input-field-container,
.chat-input .input-tools {
  transition: padding .34s var(--hm-ease), border-radius .34s var(--hm-ease);
}

/* Shorter: the field loses 8px of its own padding and the tool row loses 8px
   more, which is the height the two folded buttons were holding open. */
.chat-input.is-morphing .input-field-container { padding: 8px 14px; }
.chat-input.is-morphing .input-tools { padding: 4px 10px; }

.chat-input textarea {
  transition: opacity .2s ease;
}

/* The placeholder is swapped while the text is invisible, so it changes
   between frames instead of cutting mid-sentence. */
.chat-input.is-placeholder-out textarea { opacity: 0; }

/* ── Leaving for a domain ──────────────────────────────────────────────── */

/* Only the content column moves. The sidebar stays put, which is what says
   "same app, different room" rather than "whole new site".

   Out to the right, and the arriving page comes in from the left — so the
   motion continues in one direction across the hand-off. */
.main-content {
  will-change: transform;
}

.main-content.is-leaving {
  transform: translateX(100%);
  opacity: 0;
  transition: transform var(--hm-exit) var(--hm-ease), opacity var(--hm-exit) ease;
  pointer-events: none;
}

@media (max-width: 767px) {
  /* The sidebar is an overlay on a phone, so there is nothing to stay behind —
     the whole screen is the content column and it travels as one. */
  .main-content.is-leaving { transform: translateX(100%); }
}

/* Reduced motion: the hand-off still happens, it just does not travel. */
@media (prefers-reduced-motion: reduce) {
  .main-content.is-leaving {
    transform: none;
    transition: opacity .18s ease;
  }

  .suggest-chip {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .welcome-title,
  .welcome-line,
  .chat-input .tools-left,
  .chat-input .input-field-container,
  .chat-input .input-tools {
    transition-duration: .01ms;
  }
}

/* Composer buttons: the same size as on the tourism page. Icons 15px (18px drawn) everywhere;
   on phones the buttons are 44px, a comfortable thumb target. */
.chat-input .tools-btn, .chat-input .send-btn { font-size: 15px; }
@media (max-width: 980px) {
  .chat-input .tools-btn, .chat-input .send-btn { width: 44px; height: 44px; }
  .chat-input .send-btn { border-radius: 44px; }
}
