/* ============================================================================
   Hanamaru.ai rebuild — shared components (spec §2 + §3)
   Everything the shell (js/shell.js) and page builders need; page files
   should never add new CSS.
   Requires: tokens.css, base.css loaded first.

   CONTENTS
   --------
   1.  Pillar helpers + category chips
   2.  Buttons (.btn / .btn-primary / .btn-pill / .icon-btn)
   3.  Inputs (.input-underline) + divider
   4.  Site header (fixed, hide-on-scroll) + hamburger + logo
   5.  Pill bar (category filter pills)
   6.  Sidebar — rail + expanded states
   7.  Sidebar trending widget
   8.  Subscribe block
   9.  Socials grid
   10. Legal footer (sidebar / drawer)
   11. Mobile off-canvas drawer + scrim
   12. Mobile bottom tab bar
   13. Thumbnails + gradient placeholders
   14. Post card
   15. Ranked row (trending lists)
   16. Empty card + empty state
   17. Tab bar (underline tabs)
   18. Section head
   19. Toast
   20. Responsive (<=1024px, <768px)
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. Pillar helpers + category chips
   Apply a .pillar-* class on (or above) any chip/thumb to color it.
   ---------------------------------------------------------------------------- */
.pillar-relationships { --pillar: var(--relationships); }
.pillar-health        { --pillar: var(--health); }
.pillar-wealth        { --pillar: var(--wealth); }
.pillar-career        { --pillar: var(--career); }

.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--pillar, var(--pine));
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

a.chip:hover {
  text-decoration: none;
}

/* ----------------------------------------------------------------------------
   2. Buttons
   ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--speed-fast) var(--ease);
}

.btn:hover {
  text-decoration: none;
}

/* Vermilion CTA (Subscribe / Send) */
.btn-primary {
  background: var(--vermilion);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--vermilion-dark);
}

/* Full-width variant */
.btn-block {
  width: 100%;
  padding: 10px;
}

/* Small variant (sidebar/rail Subscribe) */
.btn-sm {
  padding: 8px 22px;
  font-size: 13px;
}

/* Small pill button ("View all", spec §3.3) */
.btn-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--sage);
  color: var(--sumi);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--speed-fast) var(--ease);
}

.btn-pill:hover {
  background: var(--sage-dark);
  text-decoration: none;
}

/* Circular ghost icon button (hamburger, drawer close, post action bar) */
.icon-btn,
.hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--icon-strong);
  cursor: pointer;
  transition: background-color var(--speed-fast) var(--ease);
}

@media (hover: hover) {
  .icon-btn:hover,
  .hamburger:hover {
    background: var(--ghost-hover);
  }
}

/* Suppress the visible focus ring on the hamburger after tap — iOS Safari
   sometimes fires :focus-visible on touch, and the button is refocused by
   closeDrawer() for keyboard a11y, which leaves a lingering ring on mobile. */
.hamburger:focus-visible {
  outline: none;
}

.icon-btn svg,
.hamburger svg {
  width: 20px;
  height: 20px;
}

/* Toggled state (like / bookmark active) */
.icon-btn.is-active {
  color: var(--vermilion);
}

/* ----------------------------------------------------------------------------
   3. Inputs + divider
   ---------------------------------------------------------------------------- */
.input-underline {
  width: 100%;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  color: var(--sumi);
  transition: border-color var(--speed-fast) var(--ease);
}

.input-underline::placeholder {
  color: var(--slate-400);
}

.input-underline:focus-visible {
  outline: none;
  border-bottom-color: var(--pine);
}

textarea.input-underline {
  resize: vertical;
  min-height: 72px;
}

.divider {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
}

/* ----------------------------------------------------------------------------
   4. Site header (spec §2.1)
   Fixed, 47px desktop, white, full bleed. Hide on scroll down via .is-hidden.
   ---------------------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  height: var(--header-h);
  background: var(--white);
  transition: transform var(--speed) var(--ease);
}

.site-header.is-hidden {
  transform: translateY(-110%);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--header-gap);
  height: 100%;
  padding: var(--space-2) var(--header-pad-x);
}

.logo {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.logo img {
  width: 160px;
  height: auto;
}

.logo__mark {
  display: none;
}

/* ----------------------------------------------------------------------------
   5. Pill bar (home header category filter, spec §2.1)
   ---------------------------------------------------------------------------- */
.pill-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-3);
  min-width: 0;
}

.pill {
  display: inline-block;
  padding: 5px 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--sage);
  color: var(--sumi);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--speed-fast) var(--ease);
}

.pill:hover {
  background: var(--sage-dark);
  text-decoration: none;
}

.pill.is-active {
  background: var(--pine);
  color: var(--white);
}

.pill.is-active:hover {
  background: var(--pine);
}

/* Center the pill bar in the header on desktop. The All + 4 pillar pills are
   final — future subcategories live on category/store pages, never up here —
   so true centering is safe. Mobile/tablet (≤1024px) keeps its own two-row
   scrollable layout (§21 overrides). */
@media (min-width: 1025px) {
  .site-header__inner {
    position: relative;
  }

  .pill-bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin-left: 0;
  }
}


/* ----------------------------------------------------------------------------
   6. Sidebar (spec §2.2) — desktop only
   States toggled by hamburger, persisted in localStorage('hana_sidebar'):
     .sidebar.is-rail      → 72px icon rail (home default)
     .sidebar.is-expanded  → 208px panel (trending/library default)
   ---------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  background: var(--white);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.sidebar:hover {
  scrollbar-color: var(--slate-300) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
}

.sidebar:hover::-webkit-scrollbar-thumb {
  background: var(--slate-300);
}

.sidebar.is-rail {
  width: var(--sidebar-rail-w);
}

.sidebar.is-expanded {
  width: var(--sidebar-w);
  padding: var(--space-3) var(--space-4);
}

/* Each state shows only its own content block */
.sidebar.is-rail .sidebar-panel,
.sidebar.is-expanded .rail-nav {
  display: none;
}

/* --- State A: icon rail --- */
.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--rail-offset-top) var(--space-2) var(--space-4) 5px;
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: 40px;
  height: 48px;
  border-radius: var(--radius-md);
  color: var(--slate-500);
  text-decoration: none;
  transition: background-color var(--speed-fast) var(--ease);
}

.rail-item:hover {
  background: var(--ghost-hover);
  text-decoration: none;
}

.rail-item svg {
  width: 22px;
  height: 22px;
}

.rail-item__label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

.rail-item.is-active {
  color: var(--nav-active);
}

/* --- State B: expanded panel --- */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: var(--space-4);
}

/* ----------------------------------------------------------------------------
   7. Sidebar trending widget (spec §2.2 B-1)
   ---------------------------------------------------------------------------- */
.trending-widget__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.trending-widget__head svg {
  width: 18px;
  height: 18px;
  color: var(--vermilion);
  flex: 0 0 auto;
}

.trending-widget__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--sumi);
}

.trending-widget .tab-bar {
  margin-top: var(--space-2);
}

.trending-widget__list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.trending-widget__card {
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: var(--space-1);
  column-gap: var(--space-2);
  color: var(--sumi);
  text-decoration: none;
}

.trending-widget__card:hover {
  color: var(--pine);
  text-decoration: none;
}

.trending-widget__card:hover .trending-widget__thumb {
  opacity: 0.9;
}

.trending-widget__rank {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--stone);
}

.trending-widget__thumb {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  transition: opacity var(--speed-fast) var(--ease);
}

.trending-widget__title-text,
.trending-widget__meta {
  grid-column: 2;
}

.trending-widget__badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.62);
  color: var(--white);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.trending-widget__title-text {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.trending-widget__meta {
  font-size: 11px;
  color: var(--stone);
}

.trending-widget__empty {
  margin-top: var(--space-3);
  font-size: 12px;
  font-style: italic;
  color: var(--slate-400);
}

/* ----------------------------------------------------------------------------
   8. Subscribe block (sidebar / drawer / about CTA; spec §2.2 B-2)
   ---------------------------------------------------------------------------- */
.subscribe-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.subscribe-block__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--sumi);
}

.subscribe-block__sub {
  font-size: 13px;
  color: var(--sumi);
}

.subscribe-block .btn {
  margin-top: var(--space-2);
  width: 100%;
}

/* ----------------------------------------------------------------------------
   8b. Toolkit shortcut card (expanded sidebar panel, above subscribe)
   Panel-only — hidden in rail state by the `.sidebar.is-rail .sidebar-panel`
   rule, so it shows only when the sidebar is expanded (2026-06-14).
   ---------------------------------------------------------------------------- */
.sidebar-toolkit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--pine) 22%, var(--border));
  border-radius: var(--radius-md);
  background: var(--washi);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sidebar-toolkit:hover {
  border-color: color-mix(in srgb, var(--pine) 50%, var(--border));
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.sidebar-toolkit__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: color-mix(in srgb, var(--pine) 12%, var(--white));
  color: var(--pine);
}

.sidebar-toolkit__icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-toolkit__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-toolkit__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--sumi);
  line-height: 1.2;
}

.sidebar-toolkit__sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--stone);
  line-height: 1.3;
}

.subscribe-success {
  font-size: 12px;
  color: var(--matcha);
}

/* ----------------------------------------------------------------------------
   9. Socials grid (spec §2.2 B-4)
   ---------------------------------------------------------------------------- */
.socials__title {
  margin-bottom: var(--space-4);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--sumi);
}

.socials__grid {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px 14px;
  justify-content: center;
  margin-inline: auto;
}

.socials__grid a {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-full);
  color: var(--vermilion);
  transition: background-color var(--speed-fast) var(--ease);
}

.socials__grid a:hover {
  background: var(--sakura);
  text-decoration: none;
}

.socials__grid svg {
  width: 16px;
  height: 16px;
}

/* ----------------------------------------------------------------------------
   10. Legal footer (pinned to sidebar bottom; reused in drawer; spec §2.2 B-5)
   ---------------------------------------------------------------------------- */
.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-2);
  padding-bottom: 24px;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) 10px;
  font-size: 12px;
}

.sidebar .legal-links {
  max-width: 100px;
}

.legal-links a {
  color: var(--slate-500);
  text-decoration: none;
}

.legal-links a:hover {
  color: var(--sumi);
  text-decoration: underline;
}

.copyright {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--slate-500);
}

.copyright svg {
  width: 12px;
  height: 12px;
}

/* ----------------------------------------------------------------------------
   11. Mobile off-canvas drawer + scrim (spec §2.4)
   Shell toggles .is-open on both; Escape / scrim tap / X close it.
   ---------------------------------------------------------------------------- */
/* Scroll lock while the drawer is open (shell.js toggles body.drawer-open) */
body.drawer-open {
  overflow: hidden;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed) var(--ease);
}

.drawer-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-drawer);
  width: var(--drawer-w);
  max-width: 85vw;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-4);
  background: var(--white);
  box-shadow: var(--shadow-drawer);
  overflow-y: auto;
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--speed) var(--ease),
              visibility 0s linear var(--speed);
}

.drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform var(--speed) var(--ease);
}

.drawer__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: calc(-1 * var(--space-4));
}

.drawer-nav {
  display: flex;
  flex-direction: column;
}

.drawer-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-2);
  border-radius: var(--radius-md);
  color: var(--sumi);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--speed-fast) var(--ease);
}

.drawer-nav a:hover {
  background: var(--ghost-hover);
  text-decoration: none;
}

.drawer-nav a svg {
  width: 20px;
  height: 20px;
  color: var(--slate-500);
  flex: 0 0 auto;
}

.drawer-nav a.is-active {
  color: var(--nav-active);
  background: var(--sage);
}

.drawer-nav a.is-active svg {
  color: var(--nav-active);
}

/* Pillar entries: hanamaru flower glyph (icons.js 'flower'), tinted by the
   .pillar-* class on the link — replaced the plain colored dot 2026-06-11 */
.drawer-nav__flower {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--pillar, var(--stone));
}

/* Extra specificity: .drawer-nav a svg sets color: var(--slate-500), which
   would otherwise out-rank the pillar tint on the svg element itself. */
.drawer-nav a .drawer-nav__flower svg {
  width: 20px;
  height: 20px;
  color: var(--pillar, var(--stone));
}

.drawer-nav__divider {
  margin: var(--space-2) 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* ----------------------------------------------------------------------------
   12. Mobile bottom tab bar (spec §2.4) — hidden on desktop, see §20
   ---------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-bottom-nav);
  display: none; /* flex on <=1024px (responsive section) */
  align-items: stretch;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  color: var(--slate-500);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
}

.bottom-nav a:hover {
  text-decoration: none;
}

.bottom-nav a svg {
  width: 22px;
  height: 22px;
}

.bottom-nav a.is-active {
  color: var(--nav-active);
}

/* ----------------------------------------------------------------------------
   13. Thumbnails + gradient placeholders (spec §3.1 / js/demo-data.js)
   .thumb wraps either an <img> or nothing (placeholder mode).
   Placeholder: pillar-colored gradient + white flower watermark (mask).
   ---------------------------------------------------------------------------- */
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  overflow: hidden;
  background: var(--card-bg);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb--placeholder {
  /* relative anchors the ::after watermark even without the base .thumb
     class (post hero) — otherwise it escapes to the viewport and shields
     whatever sits at screen center (mobile: the action-bar tip button). */
  position: relative;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--pillar, var(--sage)) 65%, var(--white)),
    var(--pillar, var(--sage))
  );
}

.thumb--placeholder::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 48px;
  height: 48px;
  background: var(--white);
  opacity: 0.55;
  -webkit-mask: url("../assets/flower.svg") center / contain no-repeat;
  mask: url("../assets/flower.svg") center / contain no-repeat;
}

.thumb__badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.62);
  color: var(--white);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 1;
}

/* ----------------------------------------------------------------------------
   14. Post card (spec §3.1) — luna3-style: hover overlay on thumb, category
       circle, kebab menu, excerpt revealed on hover.
   ---------------------------------------------------------------------------- */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 20px;
  transition: border-color var(--speed-fast) var(--ease),
              background-color var(--speed-fast) var(--ease);
}

.post-card:hover {
  padding: 9px;
  margin: -4px;
  z-index: 1;
  background-color: var(--sage); /* fallback when color-mix is unsupported */
  /* Soft wash of the card's pillar/thumbnail color — light tint, dark text
     stays legible. Mirrors the placeholder-thumb idiom (pages.css §gradient).
     Border stays transparent (no colored frame on hover) per design. */
  background-color: color-mix(in srgb, var(--pillar, var(--pine)) 12%, var(--white));
}

/* Library cards still use <a class="post-card"> */
a.post-card:hover {
  text-decoration: none;
}

/* --- Thumb link + hover overlay (luna3 dark scrim + excerpt) --- */
.post-card__thumb-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.post-card__thumb-link:hover .post-card__overlay {
  opacity: 1;
}

.post-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 20px;
  opacity: 0;
  transition: opacity var(--speed-fast) var(--ease);
}

.post-card__overlay-text {
  color: var(--white);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

/* --- Footer row: circle + title/meta + kebab --- */
.post-card__footer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.post-card__cat-circle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--pillar, var(--pine));
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.post-card__footer-body {
  flex: 1;
  min-width: 0;
}

.post-card__title-link,
.post-card__title-link:hover {
  color: inherit;
  text-decoration: none;
}

.post-card__title-link:hover .post-card__title {
  color: var(--pine);
}

.post-card__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--sumi);
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--slate-500);
}

/* --- Kebab (three vertical dots) --- */
.post-card__kebab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: 3px;
  border: 0;
  background: none;
  padding: 0;
  border-radius: var(--radius-full);
  color: var(--slate-400);
  cursor: pointer;
  transition: background-color var(--speed-fast) var(--ease);
}

.post-card__kebab:hover {
  background: var(--ghost-hover);
  color: var(--sumi);
}

.post-card:hover .post-card__kebab:hover {
  background: color-mix(in srgb, var(--pillar, var(--pine)) 18%, transparent);
  color: var(--sumi);
}

/* --- Kebab dropdown (reuses kebab-menu pattern from post rail) --- */
.post-card__kebab-menu {
  position: absolute;
  right: 8px;
  top: 100%;
  z-index: 20;
  min-width: 170px;
  padding: var(--space-1);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: none;
}

.post-card__kebab-menu.is-open {
  display: block;
}

.post-card__kebab-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  border: 0;
  background: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: left;
  color: var(--sumi);
  cursor: pointer;
}

.post-card__kebab-menu__item:hover {
  background: var(--card-bg);
}

.post-card__kebab-menu__item svg {
  width: 16px;
  height: 16px;
  color: var(--slate-500);
}

.post-card__kebab-menu__item.is-active svg {
  color: var(--vermilion);
}

/* ----------------------------------------------------------------------------
   15. Ranked row (trending page list, spec §3.2)
   ---------------------------------------------------------------------------- */
.ranked-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  color: inherit;
  text-decoration: none;
}

.ranked-row:hover {
  text-decoration: none;
}

.ranked-row:hover .ranked-row__title {
  color: var(--pine);
}

.ranked-row__rank {
  flex: 0 0 auto;
  min-width: 24px;
  font-size: 18px;
  font-weight: 800;
  color: var(--stone);
  text-align: center;
}

.ranked-row .thumb {
  flex: 0 0 120px;
  width: 120px;
  height: 68px;
  aspect-ratio: auto;
  border-radius: var(--radius-md);
}

.ranked-row__body {
  flex: 1;
  min-width: 0;
}

.ranked-row__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--sumi);
}

.ranked-row__meta {
  margin-top: var(--space-1);
  font-size: 12px;
  color: var(--slate-500);
}

/* ----------------------------------------------------------------------------
   16. Empty card + empty state
   ---------------------------------------------------------------------------- */

/* Dashed well (trending tab panels, library sections; spec §3.2/§3.3) */
.empty-card {
  padding: 28px;
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--slate-400);
  text-align: center;
}

/* Friendly centered block (home feed "Fresh content blooming soon.") */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-9) var(--space-5);
  text-align: center;
}

.empty-state__icon {
  width: 48px;
  height: 48px;
}

.empty-state__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--stone);
}

.empty-state__sub {
  font-size: 13px;
  color: var(--slate-400);
}

/* ----------------------------------------------------------------------------
   17. Tab bar — underline tabs (trending page 14px; sidebar widget 13px)
   ---------------------------------------------------------------------------- */
.tab-bar {
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--border); /* hairline across (spec §3.2) */
}

.tab {
  margin-bottom: -1px; /* underline sits on the hairline */
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--stone);
  cursor: pointer;
  transition: color var(--speed-fast) var(--ease);
}

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

.tab.is-active {
  color: var(--sumi);
  font-weight: 600;
  border-bottom-color: var(--pine);
}

/* Compact variant — sidebar trending widget (13px, spec §2.2) */
.tab-bar--compact .tab {
  padding: 6px 8px;
  font-size: 13px;
}

/* Panels: pages toggle the [hidden] attribute */
.tab-panel[hidden] {
  display: none;
}

/* ----------------------------------------------------------------------------
   18. Section head (icon + heading + optional right action)
   ---------------------------------------------------------------------------- */
.section-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-5) 0 var(--space-3);
}

.section-head svg {
  width: 18px;
  height: 18px;
  color: var(--sumi);
  flex: 0 0 auto;
}

.section-head__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--sumi);
}

/* Library sections use 17px headings (spec §3.3) */
.section-head--compact .section-head__title {
  font-size: 17px;
}

.section-head__action {
  margin-left: auto;
}

/* ----------------------------------------------------------------------------
   19. Toast (form stubs: "Subscribed! (coming soon)" — spec §7)
   ---------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + var(--space-5) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  padding: 10px 16px;
  background: var(--sumi);
  color: var(--white);
  font-size: 13px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-drawer);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed) var(--ease);
}

.toast.is-visible {
  opacity: 1;
}

/* ----------------------------------------------------------------------------
   20. Responsive (breakpoints documented in tokens.css)
   ---------------------------------------------------------------------------- */

/* Tablet + mobile (<=1024px): no sidebar, bottom nav on, header may wrap */
@media (max-width: 1024px) {
  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  /* Drawer: Home/Trending/Library live in the bottom tab bar here — drop
     the duplicates and the divider above the pillar links */
  .drawer-nav .drawer-item,
  .drawer-nav__divider {
    display: none;
  }

  /* Header: row 1 = hamburger + logo (~44px); home row 2 = scrollable pills */
  .site-header {
    height: auto;
  }

  .site-header__inner {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-h-mobile);
    padding-top: 0;
    padding-bottom: 0;
    row-gap: 0;
  }

  .pill-bar {
    order: 10;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;             /* Firefox */
    margin: 0 calc(-1 * var(--header-pad-x));
    padding: var(--space-2) var(--header-pad-x);
    padding-left: 11px;
  }

  .pill-bar::-webkit-scrollbar {
    display: none;                     /* WebKit */
  }
}

/* Homepage: center the pill row on tablet + mobile landscape only (≥600px,
   ≤1024px). Mobile portrait (<600px) keeps the default left-aligned scroll
   from the block above — reverted per request 2026-06-11. 'safe' still guards
   any width where the row would overflow, falling back to left-aligned. */
@media (min-width: 600px) and (max-width: 1024px) {
  body[data-page="home"] .pill-bar {
    justify-content: safe center;
    padding-left: var(--header-pad-x);
  }
}

/* ----------------------------------------------------------------------------
   21. Feed loading skeletons (home + category pages, js renders .skel-*)
   The shimmer is effectively disabled under prefers-reduced-motion by the
   global rule in base.css.
   ---------------------------------------------------------------------------- */
.skel-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2); /* mirrors .post-card */
}

.skel {
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--card-bg) 25%,
    var(--border) 40%,
    var(--card-bg) 60%
  );
  background-size: 300% 100%;
  animation: skel-shimmer 1.4s var(--ease) infinite;
}

.skel-thumb {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg); /* mirrors .thumb */
}

.skel-chip {
  width: 72px;
  height: 20px;
  border-radius: var(--radius-full);
}

.skel-line {
  height: 14px;
}

.skel-line--short {
  width: 60%;
}

@keyframes skel-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: 0% 0; }
}

/* Empty-state flower icon in the brand-mark vermilion */
.empty-state__icon {
  color: var(--vermilion);
}

/* ----------------------------------------------------------------------------
   22. Library cards (library page rows + history/bookmarks/liked grids)
   The remove-item affordance: small × over each card, revealed on
   hover/focus; always visible on touch devices (no hover there).
   ---------------------------------------------------------------------------- */
.card-row__item {
  position: relative;
}

.card-remove {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--white);
  color: var(--sumi);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--speed-fast) var(--ease),
              background-color var(--speed-fast) var(--ease);
}

.card-row__item:hover .card-remove,
.card-remove:focus-visible {
  opacity: 1;
}

.card-remove:hover {
  background: var(--ghost-hover);
}

.card-remove svg {
  width: 12px;
  height: 12px;
}

@media (hover: none) {
  .card-remove {
    opacity: 1;
  }
}
