/* Stormy homepage -- Treering brand colors: #1C4244 (dark) / #FFFAE7 (light). Colors are
   expressed as CSS custom properties so light/dark mode is just a variable swap. The theme
   itself is decided by public/js/theme-init.js + theme.js (time-of-day default with a
   localStorage-persisted manual override), mirroring the repo-hero dashboard -- not by
   prefers-color-scheme -- so :root holds the dark palette (the default, unclassed state) and
   html.light-mode overrides to the light palette once JS applies it. */

:root {
  --bg: #1C4244;
  --fg: #FFFAE7;
  --fg-muted: rgba(255, 250, 231, 0.75);
  --fg-dim: rgba(255, 250, 231, 0.5);
  --accent: #FFFAE7;
  --border: rgba(255, 250, 231, 0.18);
  --pill-bg: rgba(255, 250, 231, 0.1);
  --card-bg: rgba(255, 250, 231, 0.06);
  --card-border: rgba(255, 250, 231, 0.14);
  --shadow: rgba(0, 0, 0, 0.3);
}

html.light-mode {
  --bg: #FFFAE7;
  --fg: #1C4244;
  --fg-muted: rgba(28, 66, 68, 0.7);
  --fg-dim: rgba(28, 66, 68, 0.45);
  --accent: #1C4244;
  --border: rgba(28, 66, 68, 0.16);
  --pill-bg: rgba(28, 66, 68, 0.08);
  --card-bg: rgba(28, 66, 68, 0.04);
  --card-border: rgba(28, 66, 68, 0.12);
  --shadow: rgba(28, 66, 68, 0.16);
}

* {
  box-sizing: border-box;
}

/* Text selection highlight: swaps with theme so the highlight is always the theme's foreground
   color with the selected text rendered in the theme's background color for contrast. */
::selection {
  background: var(--fg);
  color: var(--bg);
}

::-moz-selection {
  background: var(--fg);
  color: var(--bg);
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
}

/* Flex items default to min-width: auto, which lets unbreakable content (e.g. the nowrap
   platform pills in .hero-tagline) force the item -- and the whole page -- wider than the
   viewport on narrow screens instead of wrapping. min-width: 0 restores normal wrapping. */
.page > * {
  min-width: 0;
  max-width: 100%;
}

a {
  color: var(--fg);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* -- Hero -------------------------------------------------------------- */

.hero {
  width: 100%;
  max-width: 640px;
  text-align: center;
  padding: 56px 0 32px;
}

.hero-logo {
  width: 180px;
  height: auto;
  max-width: 60vw;
}

h1 {
  letter-spacing: -1px;
  font-size: 3rem;
  font-weight: 700;
  margin: 12px 0 8px;
}

.hero-tagline {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg-muted);
  margin: 0 0 28px;
  line-height: 1.6;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  white-space: nowrap;
}

/* Pills are links when a platform has somewhere to send people (see platformPill() in index.js).
   They keep the badge look rather than the global link underline, using a background/color shift
   for the hover affordance instead. */
a.platform-pill {
  color: var(--fg);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

a.platform-pill:hover,
a.platform-pill:focus-visible {
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
}

.platform-pill-icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border-radius: 4px;
  vertical-align: middle;
}

/* -- Chat window mockup --------------------------------------------------- */

/* A CSS-only chat window mockup (not a screenshot) blending Slack- and Google Chat-style
   details -- a title bar with avatar/status/kebab menu, a muted message bubble, and a rounded
   pill compose bar -- with the animated typewriter text living inside the compose bar. Fully
   themed via the existing --card-bg/--pill-bg/--fg tokens so it adapts to light/dark mode. */
.chat-mock {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 12px 32px var(--shadow);
  overflow: hidden;
  text-align: left;
}

.chat-mock__titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--pill-bg);
  border-bottom: 1px solid var(--card-border);
}

.chat-mock__avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-mock__titlebar-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--fg);
}

.chat-mock__status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ba55d;
  box-shadow: 0 0 0 2px var(--pill-bg);
}

.chat-mock__menu {
  position: relative;
  margin-left: auto;
}

.chat-mock__kebab {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px;
  margin: -8px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  line-height: 0;
}

.chat-mock__kebab:hover,
.chat-mock__kebab:focus-visible {
  background: var(--card-border);
}

.chat-mock__kebab i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--fg-dim);
}

/* Small popover that shows the running bot version (pulled from package.json via
   lib/version.js), opened by clicking the kebab button in the chat mockup titlebar. */
.chat-mock__menu-popover {
  position: absolute;
  top: calc(100% + 12px);
  /* Aligns the popover's right edge with the kebab's padded box (the button carries margin: -8px)
     rather than with the 15px dot cluster, so the centered arrow clears the 10px corner radius. */
  right: -8px;
  z-index: 5;
  min-width: 170px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 12px 28px var(--shadow);
  padding: 10px 14px;
}

.chat-mock__menu-popover[hidden] {
  display: none;
}

/* The arrow is a sibling of the popover rather than a child so it can be centered on the kebab
   button: .chat-mock__menu shrink-wraps the three dots, so centering against that element puts the
   tip on the button's center regardless of the popover's width or right offset. It's ordered after
   the popover so it paints over the popover's top border, hiding the seam. */
.chat-mock__menu-popover-arrow {
  position: absolute;
  top: calc(100% + 6px);
  right: 50%;
  z-index: 6;
  width: 12px;
  height: 12px;
  background: var(--bg);
  border-left: 1px solid var(--card-border);
  border-top: 1px solid var(--card-border);
  transform: translateX(50%) rotate(45deg);
}

.chat-mock__menu-popover[hidden] + .chat-mock__menu-popover-arrow {
  display: none;
}

.chat-mock__menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.chat-mock__menu-label {
  color: var(--fg-dim);
}

.chat-mock__menu-value {
  color: var(--fg);
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chat-mock__messages {
  padding: 18px 18px 6px;
}

.chat-mock__bubble {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chat-mock__bubble-avatar {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-mock__bubble-text {
  background: var(--pill-bg);
  color: var(--fg-muted);
  padding: 8px 14px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  font-size: 0.88rem;
  line-height: 1.4;
}

.chat-mock__inputbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 18px 18px;
  padding: 12px 16px;
  background: var(--pill-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
}

.chat-mock__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--fg-dim);
  flex-shrink: 0;
}

.chat-mock__icon svg {
  width: 100%;
  height: 100%;
}

.chat-mock__icon--send {
  color: var(--accent);
}

/* -- Typewriter ---------------------------------------------------------- */

.typewriter {
  flex: 1;
  min-width: 0;
  color: var(--fg);
  font-size: 1.05rem;
  line-height: 1.4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
}

.typewriter__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.typewriter__cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 2px;
  background: currentColor;
  vertical-align: text-bottom;
  animation: stormy-caret 1s step-end infinite;
}

@keyframes stormy-caret {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

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

/* -- Info tabs (What Stormy Can Do / About Stormy / Docs) --------------- */

.info {
  width: 100%;
  max-width: 720px;
  padding: 8px 0 48px;
}

.tabs {
  display: flex;
  justify-content: flex-start;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 24px;
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 16px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--fg);
}

.tab[aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.features {
  width: 100%;
  max-width: 720px;
  padding: 8px 0 48px;
}

.features-heading {
  margin: 0 0 20px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg);
  text-align: center;
}

.features-note {
  margin: 20px 0 0;
  color: var(--fg-muted);
  font-size: 0.92rem;
  text-align: center;
}

.features-note a {
  color: var(--fg);
  font-weight: 600;
  text-decoration: underline;
}

.features-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.features-grid li {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
}

/* Small square tile icons for feature-grid entries that don't already have an emoji marker --
   sized/margined to match .platform-pill-icon so every tile reads consistently. */
.feature-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border-radius: 5px;
  vertical-align: middle;
  object-fit: cover;
}

.about-panel {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--fg-muted);
}

.about-panel p {
  margin: 0 0 16px;
}

.about-panel p:last-child {
  margin-bottom: 0;
}

.docs-intro {
  margin: 0 0 16px;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.9rem;
}

.docs-table th,
.docs-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
}

.docs-table tr:last-child td {
  border-bottom: none;
}

.docs-table th {
  font-weight: 700;
  color: var(--fg);
}

.docs-table td:first-child {
  white-space: nowrap;
  font-weight: 600;
}

.docs-table__category td {
  background: var(--pill-bg);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-dim);
  white-space: normal;
  padding-top: 8px;
  padding-bottom: 8px;
}

.docs-table code {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 0.88em;
}

@media (max-width: 560px) {
  .hero {
    padding: 40px 0 24px;
  }

  h1 {
    font-size: 2.25rem;
  }

  /* Slightly tighten the chat window mockup and typed text on narrow viewports. */
  .chat-mock__titlebar {
    padding: 12px 14px;
  }

  .chat-mock__messages {
    padding: 14px 14px 4px;
  }

  .chat-mock__inputbar {
    margin: 12px 14px 14px;
    padding: 10px 12px;
  }

  .typewriter {
    font-size: 0.92rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    gap: 0;
  }

  .tab {
    flex: 1;
    padding: 10px 6px;
    font-size: 0.85rem;
  }

  .docs-table {
    font-size: 0.82rem;
  }

  .docs-table th,
  .docs-table td {
    padding: 8px 10px;
  }
}

/* -- Footer ------------------------------------------------------------ */

.site-footer {
  width: 100%;
  max-width: 720px;
  text-align: center;
  padding: 24px 20px 32px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-dim);
}

.site-footer a:hover {
  color: var(--fg);
}

.footer-icon {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.site-footer a:hover .footer-icon {
  opacity: 1;
}

.footer-version {
  opacity: 0.6;
}

/* -- Theme toggle -------------------------------------------------------- */

.theme-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 2px 6px var(--shadow);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, opacity 0.15s ease;
}

.theme-toggle:hover {
  opacity: 0.75;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

/* Show the icon representing the CURRENT theme. */
.theme-toggle .icon-sun {
  display: none;
}

html.light-mode .theme-toggle .icon-sun {
  display: block;
}

html.light-mode .theme-toggle .icon-moon {
  display: none;
}

@media print {
  .theme-toggle {
    display: none;
  }
}
