/* ==========================================================================
   Asherfield — Homepage Shell
   Loaded only when [ash_homepage] shortcode is present.
   Depends on: ash-tokens.css, listing-shortcode.css
   All values reference CSS custom properties — no hardcoded hex.
   ========================================================================== */

/* Prevent authored display rules from overriding the [hidden] attribute */
[hidden] { display: none !important; }

/* ── Admin bar offset ────────────────────────────────────────────────────── */

:root {
  --admin-bar: var(--wp-admin--admin-bar--height, 0px);
}

/* ── Viewport breakout — escapes Blocksy's .entry-content padding ────────── */

.ash-hp-breakout {
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  overflow-x: hidden;
}

/* ── Shell grid ──────────────────────────────────────────────────────────── */

.ash-hp {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 260px;
  grid-template-areas: "left center right";
  grid-template-rows: 1fr;
  align-items: start;
  min-height: 100vh;
  width: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

/* ── Left rail ───────────────────────────────────────────────────────────── */

.ash-hp-l {
  grid-area: left;
  position: sticky;
  top: var(--admin-bar);
  height: calc(100vh - var(--admin-bar));
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  scrollbar-width: none;
}

.ash-hp-l::-webkit-scrollbar { display: none; }

/* Logo */
.ash-hp-logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.ash-hp-logo {
  display: block;
  margin-bottom: 24px;
  flex-shrink: 0;
  text-decoration: none;
}

.ash-hp-logo img {
  max-width: 130px;
  height: auto;
  display: block;
}

/* Navigation list */
.ash-hp-nav {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ash-hp-nav-item {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sidebar-foreground);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
}

.ash-hp-nav-item:hover,
.ash-hp-nav-item--active {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

/* Markets section */
.ash-hp-markets-wrap {
  margin-bottom: 20px;
}

.ash-hp-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin: 0 0 8px 10px;
}

.ash-hp-markets-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ash-hp-market-link {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sidebar-foreground);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s;
}

.ash-hp-market-link:hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

/* Rail footer */
.ash-hp-l-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ash-hp-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--ash-ring);
  color: var(--primary-foreground);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}

.ash-hp-create-btn:hover {
  background: var(--chart-5);
  color: var(--primary-foreground);
}

/* ── Center column ───────────────────────────────────────────────────────── */

.ash-hp-c {
  grid-area: center;
  min-width: 0;
  padding: 0 32px;
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */

.ash-hp-filters {
  position: sticky;
  top: var(--admin-bar);
  z-index: 10;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  margin-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.ash-hp-filters::-webkit-scrollbar { display: none; }

.ash-hp-filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ash-hp-fc {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--secondary);
  border: 1.5px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1;
}

.ash-hp-fc:hover {
  background: var(--accent);
  color: var(--foreground);
}

.ash-hp-fc.is-active {
  background: var(--ash-ring-tint);
  color: var(--ash-ring);
  border-color: var(--ash-ring);
  font-weight: 600;
}

/* Customize button */
.ash-hp-pref-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: none;
  border: 1.5px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s;
  font-family: inherit;
}

.ash-hp-pref-btn:hover {
  border-color: var(--foreground);
  color: var(--foreground);
}

/* ── Feed container ──────────────────────────────────────────────────────── */

.ash-hp-feed {
  padding: 8px 0 40px;
}

/* ── Sentinel + load more ────────────────────────────────────────────────── */

.ash-hp-sentinel {
  display: flex;
  justify-content: center;
  padding: 24px 0 48px;
}

.ash-hp-loadmore-btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 28px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ash-hp-loadmore-btn:hover {
  background: var(--secondary);
  border-color: var(--foreground);
}

.ash-hp-loadmore-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* No-JS fallback */
.ash-hp-nojs-nav {
  text-align: center;
  padding: 24px 0 48px;
}

.ash-hp-nojs-nav a {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ash-ring);
  text-decoration: none;
}

.ash-hp-nojs-nav a:hover { text-decoration: underline; }

/* ── Right rail ──────────────────────────────────────────────────────────── */

.ash-hp-r {
  grid-area: right;
  position: sticky;
  top: var(--admin-bar);
  height: calc(100vh - var(--admin-bar));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: none;
}

.ash-hp-r::-webkit-scrollbar { display: none; }

/* Rail cards */
.ash-hp-r-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.ash-hp-r-card__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin: 0 0 12px;
}

/* Auth card */
.ash-hp-r-auth__headline {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 6px;
  text-wrap: balance;
  line-height: 1.4;
}

.ash-hp-r-auth__welcome {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 12px;
  text-wrap: balance;
}

.ash-hp-r-auth__sub {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin: 0 0 14px;
  text-wrap: pretty;
  max-width: 36ch;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.ash-hp-r-auth__cta {
  display: block;
  padding: 10px 16px;
  background: var(--ash-ring);
  color: var(--primary-foreground);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s;
  margin-bottom: 8px;
}

.ash-hp-r-auth__cta:hover {
  background: var(--chart-5);
  color: var(--primary-foreground);
}

.ash-hp-r-auth__secondary {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-align: center;
  text-decoration: none;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.ash-hp-r-auth__secondary:hover {
  color: var(--foreground);
  text-decoration: underline;
}

/* Preferences summary */
.ash-hp-r-prefs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.ash-hp-r-pref-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ash-ring);
  background: var(--ash-ring-tint);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  white-space: nowrap;
}

.ash-hp-r-pref-tag button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  line-height: 1;
  font-size: 0.875rem;
}

.ash-hp-r-prefs-edit {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.ash-hp-r-prefs-edit:hover { color: var(--foreground); }

/* Trending list */
.ash-hp-r-trending-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ash-hp-r-trending-item {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
  text-decoration: none;
  transition: background 0.12s;
  cursor: pointer;
}

.ash-hp-r-trending-item:hover {
  background: var(--secondary);
}

/* Resources list */
.ash-hp-r-resources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ash-hp-r-resources-list a {
  display: block;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--foreground);
  text-decoration: none;
  transition: background 0.12s;
}

.ash-hp-r-resources-list a:hover {
  background: var(--secondary);
}

/* ── Hamburger button (mobile only) ──────────────────────────────────────── */

.ash-hp-hamburger {
  display: none;
  position: fixed;
  top: calc(var(--admin-bar) + 12px);
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--background);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
  transition: background 0.12s;
}

.ash-hp-hamburger:hover {
  background: var(--secondary);
}

/* ── Mobile drawer overlay ───────────────────────────────────────────────── */

.ash-hp-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 150;
}

/* ── Preference modal ────────────────────────────────────────────────────── */

.ash-hp-pref-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ash-hp-pref-dialog {
  background: var(--popover);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px - var(--admin-bar));
  overflow-y: auto;
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
}

.ash-hp-pref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
  gap: 12px;
}

.ash-hp-pref-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--foreground);
  margin: 0;
  text-wrap: balance;
}

.ash-hp-pref-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--muted-foreground);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.ash-hp-pref-close:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.ash-hp-pref-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.ash-hp-pref-section {}

.ash-hp-pref-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin: 0 0 10px;
}

.ash-hp-pref-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ash-hp-pref-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--secondary);
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-family: inherit;
  line-height: 1;
}

.ash-hp-pref-chip:hover {
  background: var(--accent);
  color: var(--foreground);
}

.ash-hp-pref-chip.is-active {
  background: var(--ash-ring-tint);
  color: var(--ash-ring);
  border-color: var(--ash-ring);
  font-weight: 600;
}

.ash-hp-pref-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
}

.ash-hp-pref-reset {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
}

.ash-hp-pref-reset:hover { color: var(--foreground); }

.ash-hp-pref-save {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  background: var(--ash-ring);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.ash-hp-pref-save:hover {
  background: var(--chart-5);
}

/* ── Responsive: collapse right rail at 1200px ───────────────────────────── */

@media (max-width: 1200px) {
  .ash-hp {
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas: "left center";
  }

  .ash-hp-r {
    display: none;
  }
}

/* ── Responsive: collapse left rail at 900px ─────────────────────────────── */

@media (max-width: 900px) {
  .ash-hp {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "center";
  }

  .ash-hp-l {
    position: fixed;
    top: var(--admin-bar);
    left: 0;
    height: calc(100vh - var(--admin-bar));
    width: 240px;
    z-index: 160;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-float);
  }

  .ash-hp-l.is-open {
    transform: translateX(0);
  }

  .ash-hp-drawer-overlay {
    display: block; /* visible when JS opens drawer */
  }

  .ash-hp-hamburger {
    display: flex;
  }

  .ash-hp-c {
    padding: 0 20px 0 20px;
  }

  .ash-hp-filters {
    padding-left: 48px; /* clear the hamburger button */
  }
}

/* ── Responsive: tight mobile ────────────────────────────────────────────── */

@media (max-width: 480px) {
  .ash-hp-c {
    padding: 0 16px;
  }

  .ash-hp-filters {
    padding-left: 52px;
  }

  .ash-fi {
    padding: 24px 0;
  }

  .ash-hp-pref-dialog {
    max-width: 100%;
    border-radius: var(--radius-md);
  }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ash-hp-l,
  .ash-hp-create-btn,
  .ash-hp-r-auth__cta,
  .ash-hp-fc,
  .ash-hp-pref-btn,
  .ash-hp-loadmore-btn,
  .ash-hp-pref-save {
    transition: none;
  }
}
