@import "tailwindcss";

/* Digest/thumb helpers (Bootstrap-like spec adapted to Tailwind) */
.thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2; /* slightly more vertical */
  border-radius: 0.25rem;
  overflow: hidden; /* ensure the crop is clean */
}
.thumb-wrap > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;    /* center-crop */
  object-position: center;
  display: block;
}

@supports not (aspect-ratio: auto) {
  .thumb-wrap::before {
    content: "";
    display: block;
    padding-top: calc(100% * 2 / 3); /* 3:2 aspect fallback */
  }
  .thumb-wrap > img {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
  }
}

/* Keep card fonts stable across breakpoints on digest pages */
.digest-container .card .card-title, .digest-card .card-title { font-size: 1rem; }
.digest-container .card .card-text,  .digest-card .card-text  { font-size: 0.95rem; }

/* Digest card typography – fixed sizes across breakpoints (match design) */
.dc-topic { font-size: 1rem; font-weight: 600; color: #475569; }
.dc-title { font-size: 1.5rem; line-height: 1.25; font-weight: 700; font-family: nyt-cheltenham,cheltenham-fallback-georgia,cheltenham-fallback-noto,georgia,'times new roman',times,serif; }
.dc-summary { font-size: 1.125rem; line-height: 1.55; font-family: nyt-imperial,georgia,'times new roman',times,serif; }

/* Light mode: make digest show topic tags blue (only on digest page) */
html:not(.dark) body.page-digests-show .dc-topic a { color: #2563eb; }
.dc-meta { font-size: 0.95rem; color: #64748b; }

/* Article typography – match digest card fonts for headline/snippet only */
.article-source { color: #6b7280; /* gray-500 */ }
.article-headline { font-size: 1.125rem; line-height: 1.55; color: #000000; font-weight: 700; font-family: nyt-cheltenham,cheltenham-fallback-georgia,cheltenham-fallback-noto,georgia,'times new roman',times,serif; }
.article-snippet { font-size: 1.125rem; line-height: 1.55; color: #64748b; font-family: nyt-imperial,georgia,'times new roman',times,serif; }

/* Ensure card body has equal vertical padding so image centers with self-center */
/* Remove fixed padding so per-breakpoint utility classes control spacing */
/* .digest-card { padding-top: 1rem; padding-bottom: 1rem; } */

/* Simple 2-line clamp without Tailwind plugin */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Fixed-size icon helpers to normalize SVG and emoji sizing */
.icon-16 {
  width: 16px;
  height: 16px;
  display: block;
}
.emoji-16 {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 16px;
}

/* Normalize any inline SVGs inside digest meta rows */
.dc-meta svg {
  width: 16px !important;
  height: 16px !important;
  display: block;
}

/* Nudge inline icons slightly downward to match text visual baseline */
.icon-nudge { position: relative; top: 1px; display: inline-block; }
/* Scholar icon color: match link color in light and dark modes */
.scholar-icon { color: #2563eb; }
html.dark .scholar-icon { color: #60a5fa; }

/* Desktop-only hover affordances for clickable digest cards */
@media (hover: hover) and (pointer: fine) {
  .card-clickable { cursor: pointer; }
  .digest-card {
    transition: background-color 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
  }
  .digest-card:hover {
    background-color: rgb(249 250 251); /* gray-50 */
    border-color: rgb(148 163 184);      /* gray-400 */
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  }
  /* Subtle hover for Bluesky cards - much lighter than gray-50 */
  .bsky-card { transition: background-color 120ms ease, border-color 120ms ease; }
  .bsky-card:hover { background-color: rgba(0, 0, 0, 0.02); }
}

/* Dark mode overrides */
html.dark body { background-color: #000000; color: rgb(241, 243, 245); }
html.dark a { color: #60a5fa; }
html.dark .text-black { color: rgb(241, 243, 245); }
html.dark .text-gray-700 { color: #cbd5e1; }
html.dark .text-gray-600 { color: #cbd5e1; }
html.dark .text-gray-500 { color: #94a3b8; }
html.dark .bg-white { background-color: #0b0b0b; }
html.dark .bg-white\/90 { background-color: rgba(11,11,11,0.90); }
html.dark .bg-white\/80 { background-color: rgba(11,11,11,0.80); }
html.dark .bg-white\/95 { background-color: rgba(11,11,11,0.95); }
html.dark .bg-gray-50 { background-color: #0b0b0b; }
html.dark .bg-gray-100 { background-color: #111827; }
html.dark .border { border-color: #334155; }
html.dark .border-t { border-color: #334155; }
html.dark .border-b { border-color: #334155; }
html.dark .border-gray-200 { border-color: #334155; }
html.dark .border-gray-300 { border-color: #475569; }
html.dark .border-gray-400 { border-color: #64748b; }
html.dark .hover\:bg-gray-50:hover { background-color: #111827; }
html.dark .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: #334155; }
html.dark .text-gray-500 { color: #94a3b8; }
html.dark .text-gray-700 { color: #e2e8f0; }
html.dark .text-gray-800 { color: #e5e7eb; }
html.dark .brand-text { color: #ffffff !important; }
html.dark .dc-topic { color: #94a3b8; }
html.dark .dc-meta { color: #94a3b8; }
html.dark .article-source { color: #94a3b8; }
html.dark .article-headline { color: rgb(241, 243, 245); }
html.dark .article-snippet { color: #94a3b8; }
html.dark header .border-b { border-color: #334155; }
html.dark footer { border-color: #334155; }
html.dark footer .brand-text { color: #ffffff !important; }
html.dark .digest-card { background-color: #0b0b0b; border-color: #475569; }
html.dark .digest-card:hover { background-color: #111827; border-color: #64748b; }
html.dark .bsky-card:hover { background-color: #0f1116; }
/* Match Bluesky list cards to digest card border style on large screens */
.bluesky-list-card { border-color: #e5e7eb; }
html.dark .bluesky-list-card { border-color: #475569; }
html.dark .dc-title { color: rgb(241, 243, 245); }
html.dark .dc-summary { color: #cbd5e1; }
html.dark [class*="bg-white/90"] { background-color: rgba(11,11,11,0.90); }
/* Scholar modal specific */
html.dark .modal-scholar .text-gray-600 { color: #cbd5e1; }
html.dark .modal-scholar .text-gray-800 { color: #e5e7eb; }
html.dark .modal-scholar .border { border-color: #475569; }

/* Thread connector line color – match card borders */
.thread-line { background-color: #e5e7eb; }
html.dark .thread-line { background-color: #334155; }

/* Bluesky reply text – match Bluesky mobile styles */
.bsky-reply-text {
  font-size: 15px;
  line-height: 20px;
  letter-spacing: 0;
  font-family: InterVariable, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-variant-ligatures: no-contextual;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html.dark .bsky-reply-text { color: rgb(241, 243, 245); }

/* Normalize header logos to block so they center without baseline gap */
.logo-light, .logo-dark { display: block; }
/* Swap header brand icon in dark mode */
.logo-dark { display: none; }
html.dark .logo-light { display: none !important; }
html.dark .logo-dark { display: block !important; }

/* Fallback classes for 3-column layout center width on md+ (when arbitrary values are purged) */
@media (min-width: 768px) {
  .layout-outer { display: grid; grid-template-columns: 1fr 600px 1fr; column-gap: 1.5rem; }
  .layout-center { grid-column: 2; }
  .sticky-600 { left: 50% !important; right: auto !important; transform: translateX(-50%) !important; width: 600px !important; }
}

/* Guard rails for mid-width breakpoints so content retains horizontal padding */
@media (min-width: 768px) and (max-width: 1023px) {
  header nav .py-2,
  header .border-t,
  footer .w-full {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

/* Desktop homepage/top tabs sticky bar: force centering to 600px */
@media (min-width: 768px) {
  header [data-sticky-header-target="bar"],
  header [data-sticky-header-target="bar"].fixed,
  header [data-sticky-header-target="bar"].sticky-600 {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: 600px !important;
  }
}

/* Ensure safe horizontal padding on small (sm) widths: 640–767px */
@media (min-width: 640px) and (max-width: 767px) {
  header nav { padding-left: 1rem !important; padding-right: 1rem !important; }
  main { padding-left: 1rem !important; padding-right: 1rem !important; }
  footer .w-full { padding-left: 1rem !important; padding-right: 1rem !important; }
}

/* --- Bootstrap-like buttons (subset) --- */
/* Reference: Bootstrap 5.3 buttons https://getbootstrap.com/docs/5.3/components/buttons/ */
.btn {
  display: inline-block;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem; /* ~.btn default */
  font-size: 0.875rem;     /* ~14px */
  border-radius: 0.375rem; /* .rounded */
  transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.btn-sm {
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
  border-radius: 0.35rem;
}
.btn-primary {
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
}
.btn-primary:hover { background-color: #0b5ed7; border-color: #0a58ca; }
.btn-primary:active { background-color: #0a58ca; border-color: #0a53be; }

.btn-light {
  color: #212529;
  background-color: #f8f9fa;
  border-color: #f8f9fa;
}
.btn-light:hover { background-color: #e2e6ea; border-color: #dae0e5; }
.btn-light:active { background-color: #d3d9df; border-color: #cbd3da; }

/* Ensure buttons look correct in dark mode */
html.dark .btn-secondary { color: #fff; }
html.dark .btn { box-shadow: none; }

/* Bluesky CTA heading typography */
.cta-bsky-heading {
  font-size: 24.375px; /* Bluesky size */
  color: rgb(11, 15, 20);
  font-weight: 800;                 /* heavy like Bluesky */
  /* Slightly more open feel like bsky rendering */
  letter-spacing: 0.2px;            /* fallback if font-stretch not supported */
  font-stretch: 105%;               /* widen glyphs a touch (variable fonts) */
  font-variation-settings: "wdth" 105, "wght" 800; /* InterVariable-friendly */
  line-height: 32px;                /* more room between lines */
  margin-bottom: 1.25rem;           /* more space before buttons */
  /* Same family we use app-wide */
  font-family: InterVariable, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-variant-ligatures: no-contextual;
}
html.dark .cta-bsky-heading { color: rgb(241,243,245); }
