/* Ferebook guides — shared stylesheet for static SEO articles.
   Mirrors the Apple-style design tokens used by app/globals.css. */

:root {
  color-scheme: light;

  --color-bg: #ffffff;
  --color-bg-secondary: #f5f5f7;
  --color-text: #1d1d1f;
  --color-text-secondary: #6e6e73;
  --color-text-muted: #86868b;
  --color-border: #d2d2d7;
  --color-border-soft: rgba(210, 210, 215, 0.55);
  --color-nav-bg: rgba(255, 255, 255, 0.72);
  --color-card-bg: #fbfbfd;
  --color-link: #0066cc;
  --color-button: #0071e3;
  --color-button-hover: #0077ed;
  --color-panel-dark-bg: #1d1d1f;
  --color-panel-dark-text: #ffffff;
  --color-panel-dark-desc: #a1a1a6;
  --color-mark-bg: #ffe9a8;
  --color-scrollbar: rgba(0, 0, 0, 0.15);
  --color-scrollbar-hover: rgba(0, 0, 0, 0.3);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);

  --nav-height: 52px;
  --content-max: 720px;
  --wide-max: 980px;
}

/* Time-based dark theme (19:00–07:00), driven by data-theme from theme-schedule.js.
   Matches app/globals.css — do not use prefers-color-scheme here. */
[data-theme="dark"] {
  color-scheme: dark;

  --color-bg: #000000;
  --color-bg-secondary: #1c1c1e;
  --color-text: #f5f5f7;
  --color-text-secondary: #a1a1a6;
  --color-text-muted: #86868b;
  --color-border: #38383a;
  --color-border-soft: rgba(56, 56, 58, 0.8);
  --color-nav-bg: rgba(29, 29, 31, 0.8);
  --color-card-bg: #1c1c1e;
  --color-link: #2997ff;
  --color-button: #0a84ff;
  --color-button-hover: #409cff;
  --color-panel-dark-bg: #1c1c1e;
  --color-panel-dark-text: #f5f5f7;
  --color-panel-dark-desc: #a1a1a6;
  --color-mark-bg: #3d3520;
  --color-scrollbar: rgba(255, 255, 255, 0.2);
  --color-scrollbar-hover: rgba(255, 255, 255, 0.35);
  --shadow-card: none;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "SF Pro Display", "SF Pro Icons", -apple-system,
    BlinkMacSystemFont, "Helvetica Neue", "Helvetica", "Arial", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 17px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-link);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.015em;
  font-weight: 600;
  color: var(--color-text);
}

mark {
  background: var(--color-mark-bg);
  color: var(--color-text);
  padding: 0 3px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-button);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

/* ── Navbar — matches components/layout/Navbar.tsx ── */
.site-nav {
  /* sticky keeps nav in document flow — no huge padding-top to clear a fixed bar */
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 50;
  height: var(--nav-height);
  background: var(--color-nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-border-soft);
}

.site-nav-inner {
  max-width: 1140px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-text);
}

.site-nav .brand:hover {
  text-decoration: none;
}

.site-nav .brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.site-nav .brand-icon img,
.site-nav .brand-logo {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 13px;
}

.nav-links a {
  color: var(--color-text);
  opacity: 0.8;
}

.nav-links a:hover {
  opacity: 1;
  text-decoration: none;
}

.nav-links a[aria-current="page"] {
  font-weight: 600;
  opacity: 1;
}

.nav-cta {
  background: var(--color-button);
  color: #fff !important;
  border-radius: 980px;
  padding: 6px 16px;
  font-weight: 500;
  opacity: 1 !important;
}

.nav-cta:hover {
  background: var(--color-button-hover);
  text-decoration: none;
}

@media (max-width: 720px) {
  .nav-links .nav-hide-sm {
    display: none;
  }
  .nav-links {
    gap: 14px;
  }
}

/* ── Breadcrumb ── */
.breadcrumb {
  max-width: var(--wide-max);
  margin: 0 auto;
  /* Nav is sticky (in-flow); only a short gap below it. */
  padding: 12px 24px 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.breadcrumb a {
  color: var(--color-text-secondary);
}

.breadcrumb [aria-current="page"] {
  color: var(--color-text-muted);
}

.breadcrumb .sep {
  opacity: 0.5;
}

/* ── Article header ── */
.article-head {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 6px 24px 8px;
}

.eyebrow {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.article-head h1 {
  font-size: clamp(28px, 2.8vw + 12px, 40px);
  line-height: 1.15;
  max-width: 900px;
}

.article-head .dek {
  margin-top: 18px;
  font-size: clamp(17px, 0.8vw + 13px, 21px);
  line-height: 1.45;
  color: var(--color-text-secondary);
  max-width: 720px;
}

.article-meta {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ── Main column ── */
.article-body {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 8px 24px 72px;
}

.article-body > section {
  margin-top: 48px;
  scroll-margin-top: calc(var(--nav-height) + 24px);
}

.article-body h2 {
  font-size: clamp(24px, 1.6vw + 18px, 32px);
  line-height: 1.12;
  margin-bottom: 16px;
}

.article-body h3 {
  font-size: clamp(19px, 0.8vw + 15px, 22px);
  line-height: 1.2;
  margin: 28px 0 10px;
}

.article-body p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.article-body strong {
  color: var(--color-text);
  font-weight: 600;
}

.article-body ul,
.article-body ol {
  margin: 0 0 18px 22px;
}

.article-body li {
  font-size: 17px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.article-body li::marker {
  color: var(--color-text-muted);
}

/* ── Table of contents ── */
.toc {
  margin-top: 32px;
  padding: 20px 22px;
  background: var(--color-bg-secondary);
  border-radius: 14px;
}

.toc-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.toc ol {
  list-style: none;
  margin: 0;
  columns: 2;
  column-gap: 28px;
}

.toc li {
  margin: 0 0 6px;
  font-size: 15px;
  break-inside: avoid;
}

.toc a {
  color: var(--color-text-secondary);
}

.toc a:hover {
  color: var(--color-link);
}

@media (max-width: 640px) {
  .toc ol {
    columns: 1;
  }
}

/* ── Callouts and key takeaways ── */
.callout {
  background: var(--color-bg-secondary);
  border-radius: 14px;
  padding: 18px 22px;
  margin: 22px 0;
}

.callout p {
  margin-bottom: 0;
  color: var(--color-text);
  font-size: 16px;
}

.callout p + p {
  margin-top: 10px;
}

.callout-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.callout-answer {
  border: 1px solid var(--color-border-soft);
  background: var(--color-card-bg);
  box-shadow: var(--shadow-card);
}

.callout-answer h2 {
  font-size: 20px;
  margin: 0 0 12px;
}

.callout-answer .table-wrap {
  margin: 12px 0 16px;
}

.cta-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 8px 0 0;
}

.fit-grid {
  list-style: none;
  margin: 12px 0 20px;
  padding: 0;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .fit-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.fit-grid li {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--color-bg-secondary);
  font-size: 15px;
  line-height: 1.45;
  color: var(--color-text-secondary);
}

.fit-grid li strong {
  color: var(--color-text);
  font-weight: 600;
}

.takeaways {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border-soft);
  border-radius: 16px;
  padding: 22px 24px;
  margin-top: 32px;
  box-shadow: var(--shadow-card);
}

.takeaways ul {
  margin: 0 0 0 20px;
}

.takeaways li:last-child {
  margin-bottom: 0;
}

/* ── Steps ── */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0 0 18px;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 0 44px;
  margin-bottom: 22px;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.steps h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.steps p {
  margin-bottom: 0;
  font-size: 16px;
}

/* ── Comparison tables ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 22px 0;
  border: 1px solid var(--color-border-soft);
  border-radius: 14px;
}

/* Break a dense comparison table out of the reading column so it needs
   less horizontal scrolling on wide screens. */
.table-wrap--wide {
  width: min(var(--wide-max), calc(100vw - 48px));
  margin-left: 50%;
  transform: translateX(-50%);
}

table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 15px;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 14px 18px 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--color-text-secondary);
  line-height: 1.45;
}

thead th {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg-secondary);
  white-space: nowrap;
}

tbody th {
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

/* ── Figures ── */
figure {
  margin: 26px 0;
}

figure img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--color-border-soft);
  display: block;
}

figcaption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── FAQ ── */
.faq-item {
  border-bottom: 1px solid var(--color-border-soft);
  padding: 18px 0;
}

.faq-item:first-of-type {
  border-top: 1px solid var(--color-border-soft);
}

.faq-item h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.faq-item p:last-child {
  margin-bottom: 0;
}

/* ── Inline CTA card ── */
.cta-card {
  margin: 40px 0 0;
  background: var(--color-panel-dark-bg);
  color: var(--color-panel-dark-text);
  border-radius: 20px;
  padding: 32px 34px;
}

.cta-card h2 {
  color: var(--color-panel-dark-text);
  font-size: clamp(22px, 1.4vw + 16px, 28px);
  margin-bottom: 10px;
}

.cta-card p {
  color: var(--color-panel-dark-desc);
  font-size: 16px;
  margin-bottom: 20px;
  max-width: 560px;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 980px;
  font-size: 15px;
  font-weight: 500;
  padding: 10px 22px;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.btn-primary {
  background: var(--color-button);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-button-hover);
  text-decoration: none;
}

.btn-secondary {
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
}

.cta-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--color-panel-dark-desc);
}

/* ── Related guides ── */
.related {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 0 24px 72px;
}

.related h2 {
  font-size: clamp(22px, 1.4vw + 16px, 28px);
  margin-bottom: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.guide-card {
  display: block;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border-soft);
  border-radius: 16px;
  padding: 22px;
  color: inherit;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.guide-card:hover {
  border-color: var(--color-border);
  text-decoration: none;
  transform: translateY(-2px);
}

.guide-card .kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.guide-card h3 {
  font-size: 17px;
  line-height: 1.3;
  margin-bottom: 8px;
}

.guide-card p {
  font-size: 14px;
  line-height: 1.45;
  color: var(--color-text-secondary);
  margin: 0;
}

/* ── Guide card: cover, meta and affordance ── */
.guide-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* Text-only cards (Keep reading, and any future card without a cover) put the
   kicker as the first child. Restore inset padding so border-radius +
   overflow:hidden cannot clip the first letter of the uppercase label.
   Hub cards keep padding:0 because they start with .cover / .card-body. */
.guide-card:has(> .kicker:first-child),
.related .guide-card {
  padding: 22px;
}

.guide-card > .card-body {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.guide-card .card-desc {
  flex: 1;
}

/* Typographic covers — no image assets, one visual language for every guide. */
.cover {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 40px;
  padding: 0 16px;
  background: linear-gradient(135deg, #eaf1fc, #dce8fb);
  border-bottom: 1px solid var(--color-border-soft);
}

.cover span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #14448f;
  line-height: 1.2;
}

.cover--read {
  background: linear-gradient(135deg, #fdf1e5, #f9e5d2);
}

.cover--read span {
  color: #8a4c17;
}

.cover--pillar {
  background: linear-gradient(135deg, #1d1d1f, #3a3a3c);
  border-bottom-color: transparent;
}

.cover--pillar span {
  color: #ffffff;
}

[data-theme="dark"] .cover {
  background: linear-gradient(135deg, #10243f, #16324f);
}
[data-theme="dark"] .cover span {
  color: #8fc0ff;
}
[data-theme="dark"] .cover--read {
  background: linear-gradient(135deg, #33220f, #45301a);
}
[data-theme="dark"] .cover--read span {
  color: #f0b57a;
}
[data-theme="dark"] .cover--pillar {
  background: linear-gradient(135deg, #2c2c2e, #48484a);
}

.card-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-soft);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.card-more {
  color: var(--color-link);
  font-weight: 500;
}

/* Featured guide — spans two columns with a taller cover. */
.guide-card--featured {
  grid-column: span 2;
}

.guide-card--featured .cover {
  height: 40px;
}

.guide-card--featured .cover span {
  font-size: 12px;
}

.guide-card--featured h3 {
  font-size: clamp(20px, 1.2vw + 15px, 25px);
}

.guide-card--featured .card-desc {
  font-size: 15px;
}

@media (max-width: 720px) {
  .guide-card--featured {
    grid-column: span 1;
  }
  .guide-card--featured .cover {
    height: 40px;
  }
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.chip {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-bg-secondary);
  border: 1px solid transparent;
  border-radius: 980px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.chip:hover {
  border-color: var(--color-border);
}

.chip[aria-pressed="true"] {
  background: var(--color-text);
  color: var(--color-bg);
}

.filter-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Filtering toggles [hidden]; guide cards set display:flex, so override it. */
[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .filter-count {
    margin-left: 0;
    width: 100%;
  }
}

/* ── Hub page ── */
.hub-hero {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 20px 24px 0;
}

.hub-hero h1 {
  font-size: clamp(28px, 3vw + 12px, 44px);
  line-height: 1.12;
}

.hub-hero .dek {
  margin-top: 18px;
  font-size: clamp(17px, 0.8vw + 13px, 21px);
  line-height: 1.45;
  color: var(--color-text-secondary);
  max-width: 680px;
}

.hub-meta {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.hub-section {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 56px 24px 0;
}

.hub-section:last-of-type {
  padding-bottom: 72px;
}

.hub-section h2 {
  font-size: clamp(24px, 1.6vw + 18px, 32px);
  margin-bottom: 8px;
}

.hub-section .section-intro {
  font-size: 17px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  max-width: 680px;
  margin-bottom: 24px;
}

/* ── Footer — matches components/layout/Footer.tsx ── */
.site-footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border-soft);
}

.site-footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border-soft);
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-support {
    text-align: right;
  }
}

.footer-brand {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.footer-tagline {
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-top: 8px;
  max-width: 24rem;
}

.footer-support h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
}

.footer-support ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-support a {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.footer-support a:hover {
  color: var(--color-link);
  text-decoration: none;
}

.footer-copy {
  padding-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-scrollbar);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-scrollbar-hover);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .guide-card:hover {
    transform: none;
  }
}
