/* shared/theme/branding/homepage.css
   Homepage styling inspired by Docker docs.
   Provides hero section, chat bar, quick question chips,
   navigation cards, and featured topics list.

   This file is loaded after colors.css, so all --pg-* variables are available.
*/

/* ============================================================
   HOMEPAGE-SPECIFIC SEMANTIC TOKENS
   These reference the shared --pg-* and --md-* variables from colors.css
   ============================================================ */
:root {
  /* Light theme semantic mappings */
  --home-bg-card: var(--md-default-bg-color--light);
  --home-bg-card-hover: var(--md-default-bg-color);
  --home-text-primary: var(--md-default-fg-color);
  --home-text-secondary: var(--md-default-fg-color--light);
  --home-border: var(--pg-gray-400);
  --home-accent: var(--md-accent-fg-color);
  --home-icon-fg: var(--pg-white);
  --home-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --home-shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Dark mode - references dark mode variables from colors.css */
[data-md-color-scheme="slate"] {
  --home-bg-card: var(--md-default-bg-color--light);
  --home-bg-card-hover: var(--md-default-bg-color);
  --home-text-primary: var(--md-default-fg-color);
  --home-text-secondary: var(--md-default-fg-color--light);
  --home-border: var(--md-default-fg-color--lighter);
  --home-accent: var(--md-accent-fg-color);
  --home-icon-fg: var(--pg-white);
  --home-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --home-shadow-subtle: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   HOMEPAGE CONTAINER
   ============================================================ */
.pg-home {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.5rem 1rem 2rem;
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.pg-hero {
  text-align: left;
  margin-bottom: 3rem;
}

.pg-hero h1 {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
}

.pg-hero h2 {
  text-align: center;
}

/* ============================================================
   INLINE CHAT COMPONENT (.pgc-*)
   ============================================================ */
.pgc-root {
  max-width: 800px;
  margin: 0 auto 1.5rem;
  border: 1px solid var(--home-border);
  border-radius: 1rem;
  background: var(--home-bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pgc-messages {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

.pgc-root[data-active] .pgc-messages {
  display: flex;
}

.pgc-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
  text-align: left;
}

.pgc-bubble--user {
  background: var(--home-accent);
  color: var(--home-icon-fg);
  align-self: flex-end;
  border-bottom-right-radius: 0.25rem;
}

.pgc-bubble--ai {
  background: var(--md-default-bg-color--light);
  color: var(--home-text-primary);
  border: 1px solid var(--home-border);
  align-self: flex-start;
  border-bottom-left-radius: 0.25rem;
}

/* Markdown content inside AI bubbles */
.pgc-bubble--ai p { margin: 0 0 0.75rem; }
.pgc-bubble--ai p:last-child { margin-bottom: 0; }
.pgc-bubble--ai pre {
  background: var(--md-code-bg-color);
  border-radius: 0.5rem;
  padding: 0.75rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.85em;
}
.pgc-bubble--ai code {
  background: var(--md-code-bg-color);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  font-size: 0.85em;
}
.pgc-bubble--ai pre code { background: none; padding: 0; }
.pgc-bubble--ai ul,
.pgc-bubble--ai ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.pgc-bubble--ai li { margin: 0.2rem 0; }
.pgc-bubble--ai a { color: var(--home-accent); }
.pgc-bubble--ai h1,
.pgc-bubble--ai h2,
.pgc-bubble--ai h3 { margin: 0.75rem 0 0.25rem; font-weight: 600; }

/* Thinking animation */
.pgc-thinking {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 0.25rem 0;
}

.pgc-thinking span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--home-text-secondary);
  animation: pgc-bounce 1.4s infinite ease-in-out;
}

.pgc-thinking span:nth-child(2) { animation-delay: 0.2s; }
.pgc-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pgc-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Blinking cursor during streaming */
.pgc-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: pgc-blink 1s step-end infinite;
}

@keyframes pgc-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Input row */
.pgc-input-row {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid transparent;
}

.pgc-root[data-active] .pgc-input-row {
  border-top-color: var(--home-border);
}

.pgc-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pgc-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--home-text-primary);
  font-size: 0.95rem;
  outline: none;
  padding: 0.25rem 0;
  min-width: 0;
}

.pgc-input::placeholder { color: var(--home-text-secondary); }

.pgc-submit {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0.4rem;
  border: none;
  border-radius: 50%;
  background: var(--home-accent);
  color: var(--home-icon-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.pgc-submit:disabled { opacity: 0.4; cursor: not-allowed; }
.pgc-submit svg { width: 100%; height: 100%; fill: currentColor; }

/* Sources */
.pgc-sources {
  border-top: 1px solid var(--home-border);
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  font-size: 0.8rem;
}

.pgc-sources-label {
  color: var(--home-text-secondary);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.pgc-source {
  display: block;
  color: var(--home-accent);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.2rem;
}

.pgc-source:hover { text-decoration: underline; }

/* Footer */
.pgc-footer {
  padding: 0.4rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--home-text-secondary);
  border-top: 1px solid var(--home-border);
}

.pgc-footer a { color: inherit; text-decoration: none; }
.pgc-footer a:hover { text-decoration: underline; }

/* Error state */
.pgc-error { color: var(--pg-danger, #f44336); font-style: italic; }


.pgc-sources-label {
  color: var(--home-text-secondary);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.pgc-source {
  display: block;
  color: var(--home-accent);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.2rem;
}

.pgc-source:hover { text-decoration: underline; }

/* Footer */
.pgc-footer {
  padding: 0.4rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--home-text-secondary);
  border-top: 1px solid var(--home-border);
}

.pgc-footer a { color: inherit; text-decoration: none; }
.pgc-footer a:hover { text-decoration: underline; }

/* Error state */
.pgc-error { color: var(--pg-danger, #f44336); font-style: italic; }


/* ============================================================
   QUICK QUESTION CHIPS
   ============================================================ */
.pg-quick-questions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pg-chip {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--home-bg-card);
  border: 1px solid var(--home-border);
  border-radius: 1.5rem;
  color: var(--home-text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.pg-chip:hover {
  border-color: var(--home-accent);
  color: var(--home-accent);
  background: var(--home-bg-card-hover);
}

/* ============================================================
   NAVIGATION CARDS GRID
   ============================================================ */
.pg-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 3rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 600px) {
  .pg-cards-grid {
    grid-template-columns: 1fr;
  }
}

.pg-card {
  display: flex;
  align-items: flex-start;
  padding: 1.25rem;
  background: var(--home-bg-card);
  border: 1px solid var(--home-border);
  border-radius: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
}

.pg-card:hover {
  border-color: var(--home-accent);
  box-shadow: var(--home-shadow-subtle);
}

.pg-card-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: 1rem;
  padding: 0.5rem;
  background: var(--home-accent);
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pg-card-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: var(--home-icon-fg);
}

.pg-card-content {
  min-width: 0;
}

.pg-card-content h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--home-text-primary);
}

.pg-card-content p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--home-text-secondary);
  line-height: 1.4;
}

/* ============================================================
   FEATURED TOPICS
   ============================================================ */
.pg-featured {
  max-width: 700px;
  margin: 0 auto;
}

.pg-featured h2 {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.pg-featured-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--home-bg-card);
  border: 1px solid var(--home-border);
  border-bottom: none;
  color: var(--home-text-primary);
  text-decoration: none;
  transition: background 0.2s;
}

.pg-featured-item:first-of-type {
  border-radius: 0.5rem 0.5rem 0 0;
}

.pg-featured-item:last-of-type {
  border-bottom: 1px solid var(--home-border);
  border-radius: 0 0 0.5rem 0.5rem;
}

.pg-featured-item:hover {
  background: var(--home-bg-card-hover);
}

.pg-featured-arrow svg {
  width: 1rem;
  height: 1rem;
  fill: var(--home-text-secondary);
  transition: fill 0.2s, transform 0.2s;
}

.pg-featured-item:hover .pg-featured-arrow svg {
  fill: var(--home-accent);
  transform: translateX(4px);
}

/* ============================================================
   DEFINITION LISTS (Glossary styling)
   Used for glossary pages and term definitions throughout docs.
   ============================================================ */
dl {
  margin: 1.5rem 0;
}

dt {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--md-default-fg-color);
  padding: 0.75rem 0 0.25rem 0;
  border-bottom: 2px solid var(--md-primary-fg-color);
  margin-bottom: 0.25rem;
}

dd {
  margin-left: 0;
  padding: 0.5rem 0 1rem 1rem;
  border-left: 3px solid var(--md-default-fg-color--lighter);
  color: var(--md-default-fg-color--light);
}

dd p {
  margin: 0;
}

/* Hover effect for terms */
dt:hover {
  color: var(--md-accent-fg-color);
}

/* Dark mode adjustments */
[data-md-color-scheme="slate"] dt {
  border-bottom-color: var(--md-accent-fg-color);
}

[data-md-color-scheme="slate"] dd {
  border-left-color: var(--md-default-fg-color--lighter);
}
