/* ===================================================================
   Tiny Sleeps — shared cards: guide cards, the app card, "jump to a section".
   Loaded by the homepage, the guides index and every guide. Tokens from styles.css.
   =================================================================== */

/* --- Guide cards --- */
.guide-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}
.guide-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.guide-card:hover { box-shadow: var(--shadow-md); border-color: var(--color-text-secondary); }
/* Keyboard focus rings the whole card (the link's own ring would only box the title). */
.guide-card:has(a:focus-visible) { outline: 2px solid var(--color-text); outline-offset: 2px; }
.guide-card .guide-card-topic {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}
.guide-card .guide-card-title { font-size: 1.125rem; line-height: 1.35; margin-bottom: 0.5rem; }
/* The whole card is the tap target; the link text stays the accessible name. */
.guide-card .guide-card-title a::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius-lg); }
.guide-card .guide-card-title a:focus-visible { outline: none; }
.guide-card .guide-card-summary { font-size: 0.9375rem; line-height: 1.6; margin-bottom: 0.75rem; color: var(--color-text-secondary); }
.guide-card .guide-card-meta { margin: auto 0 0; font-size: 0.8125rem; color: var(--color-text-secondary); }
@media (max-width: 960px) { .guide-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .guide-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .guide-card { padding: 1rem 1.1rem; }
  .guide-card .guide-card-title { font-size: 1.05rem; }
  /* Phones: two lines of summary, so more guides fit on a screen. */
  .guide-card .guide-card-summary {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
}

/* --- Homepage: "From our guides" --- */
.home-guides-header { text-align: center; max-width: 600px; margin: 0 auto var(--space-lg); }
.home-guides-header .section-subtitle { margin: 0 auto; }
.home-guides .home-guides-more { text-align: center; max-width: none; margin: var(--space-md) auto 0; font-weight: 500; }
.home-guides-more a { text-decoration: underline; text-underline-offset: 3px; }

/* --- App card (end of every guide) --- */
.app-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.app-card-icon { width: 72px; height: 72px; border-radius: 16px; flex-shrink: 0; }
.app-card-body { flex: 1; min-width: 0; }
.app-card .app-card-name { font-family: var(--font-heading); font-weight: 700; font-size: 1.15rem; margin: 0 0 0.2rem; }
.app-card .app-card-line { margin: 0; font-size: 1rem; }
.app-card .app-card-line a { text-decoration: underline; text-underline-offset: 3px; }
/* The card sits inside .prose, whose link styles would otherwise darken and underline the badge. */
.app-card .app-card-badge { flex-shrink: 0; color: var(--color-white); text-decoration: none; }
@media (max-width: 640px) {
  .app-card { flex-wrap: wrap; }
  .app-card-icon { width: 56px; height: 56px; border-radius: 13px; }
  .app-card-badge { width: 100%; justify-content: center; }
}

/* --- "More guides" at the end of a guide --- */
.more-guides { margin-top: var(--space-xl); }
.more-guides h2 { font-size: clamp(1.4rem, 3vw, 1.75rem); margin-bottom: var(--space-md); }
.more-guides .guide-grid { grid-template-columns: repeat(2, 1fr); }
/* An odd count would leave one card alone on the last row: let it span both columns. */
.more-guides .guide-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (max-width: 640px) { .more-guides .guide-grid { grid-template-columns: 1fr; } }

/* --- "Jump to a section" --- */
.toc {
  margin: var(--space-md) 0 var(--space-lg);
  padding: 0.9rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}
.toc summary { cursor: pointer; font-weight: 600; font-size: 0.9375rem; }
/* Selectors outrank .prose ol/li/a (the list sits inside the article). */
.toc ol.toc-list { margin: 0.75rem 0 0.25rem 1.25rem; }
.toc ol.toc-list li { font-size: 0.9375rem; line-height: 1.5; margin: 0.35rem 0; }
.toc ol.toc-list a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; text-decoration-color: var(--color-text-secondary); }
.toc ol.toc-list a:hover { text-decoration-color: currentColor; }

/* --- Footer on phones (S2.10): an even two-column grid instead of a ragged wrap that left
   one link alone on the last line. Lives here, not in styles.css (a carried-over file). --- */
@media (max-width: 640px) {
  .footer .footer-links {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: center;
    gap: 0.75rem var(--space-lg);
  }
}

/* --- Homepage: "Inside the app" tour (S2.7): one phone, the reader picks the screen --- */
.tour {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: var(--space-xl);
  align-items: center;
  max-width: 920px;
  margin: 0 auto;
}
.tour-list { display: flex; flex-direction: column; gap: 0.5rem; }
.tour-tab {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.tour-tab:hover { background: rgba(250, 252, 254, 0.6); }
.tour-tab[aria-selected='true'] {
  background: var(--color-card);
  border-color: var(--color-border);
  border-left-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}
.tour-tab:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }
.tour-tab-title { display: block; font-family: var(--font-heading); font-weight: 600; font-size: 1.05rem; }
.tour-tab-line { display: block; margin-top: 0.3rem; font-size: 0.9375rem; line-height: 1.55; color: var(--color-text-secondary); }
/* Only the chosen feature shows its line, so the list stays quiet (all lines show if JavaScript is off). */
.tour-ready .tour-tab[aria-selected='false'] .tour-tab-line { display: none; }

.tour-phone {
  position: relative;
  width: 280px;
  aspect-ratio: 1125 / 2436;
  box-sizing: content-box;
  background: #1a1a1a;
  border-radius: 40px;
  padding: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
/* Panels are stacked; opacity (not display) so lazy images still load before they're chosen. */
.tour-panel { position: absolute; inset: 4px; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
/* Only the chosen screen is on top and clickable (long-press / save image hits the right one). */
.tour-panel[data-active] { opacity: 1; pointer-events: auto; z-index: 1; }
.tour-panel img { width: 100%; height: 100%; display: block; border-radius: 36px; }
@media (prefers-reduced-motion: reduce) { .tour-panel { transition: none; } }

.tour-tab-short, .tour-caption { display: none; }

/* Phones and small tablets: the phone, then a row of short labels right under it, then the chosen
   screen's words, so a tap never changes a picture the reader can't see. Without JavaScript the
   full list stays (every line visible), since the labels would do nothing. */
@media (max-width: 800px) {
  .tour { grid-template-columns: 1fr; gap: var(--space-sm); justify-items: center; }
  .tour-phone { order: 1; width: 190px; border-radius: 30px; }
  .tour-panel img { border-radius: 26px; }
  .tour-list { order: 3; width: 100%; max-width: 480px; }
  .tour-ready .tour-list { order: 2; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
  .tour-ready .tour-tab {
    width: auto;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-card);
    box-shadow: none;
  }
  .tour-ready .tour-tab[aria-selected='true'] { background: var(--color-text); border-color: var(--color-text); color: var(--color-white); }
  .tour-ready .tour-tab-short { display: block; font-size: 0.875rem; font-weight: 500; }
  /* Visually hidden but still the button's name for screen readers (the short label is aria-hidden). */
  .tour-ready .tour-tab-title, .tour-ready .tour-tab-line {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .tour-ready .tour-tab { position: relative; }
  .tour-ready .tour-caption {
    display: block;
    order: 3;
    max-width: 420px;
    margin: 0.25rem auto 0;
    text-align: center;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--color-text-secondary);
  }
  .tour-ready .tour-caption strong { display: block; color: var(--color-text); font-family: var(--font-heading); font-weight: 600; }
}

/* --- Homepage FAQ (S2.8): tap-to-open questions; answers stay in the HTML for search and AI --- */
.home-faq .faq-list { max-width: 760px; margin: 0 auto; display: grid; gap: 0.6rem; }
.faq-q {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.faq-q summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: 1rem 1.25rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.4;
  color: var(--color-text);
}
.faq-q summary::-webkit-details-marker { display: none; }
/* The question is its own flex item so long questions always wrap beside the chevron. */
.faq-q .faq-q-text { flex: 1; min-width: 0; }
.faq-q summary::after {
  content: '';
  flex-shrink: 0;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--color-text-secondary);
  border-bottom: 2px solid var(--color-text-secondary);
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--transition-fast);
}
.faq-q[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.faq-q summary:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; border-radius: var(--radius-md); }
.home-faq .faq-q p { max-width: none; margin: 0; padding: 0 1.25rem 1.1rem; font-size: 1rem; line-height: 1.65; color: var(--color-text-secondary); }
@media (prefers-reduced-motion: reduce) { .faq-q summary::after { transition: none; } }
