/* Coffee Notebook — components
 * Reusable UI: rating chips, filter chips, cards, sidebars, timeline pieces.
 * Reads tokens from tokens.css.
 */

/* ── Rating chip ────────────────────────────────────────── */
.rating {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2em 0.55em;
  border-radius: 999px;
  vertical-align: middle;
}

.rating-outstanding { background: var(--rating-outstanding-bg); color: var(--rating-outstanding-text); }
.rating-great       { background: var(--rating-great-bg);       color: var(--rating-great-text); }
.rating-average     { background: var(--rating-average-bg);     color: var(--rating-average-text); }
.rating-pass        { background: var(--rating-pass-bg);        color: var(--rating-pass-text); }

/* ── Filter chips ──────────────────────────────────────── */
.filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  padding: var(--space-5, 1.25rem) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.filter-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: var(--space-4);
  align-items: start;
}

.filter-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
  padding-top: 0.45em;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-chip {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  padding: 0.35em 0.75em;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0;
  transition: border-color var(--duration) var(--ease),
              color var(--duration) var(--ease),
              background var(--duration) var(--ease);
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.filter-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

.filter-chip-flag {
  margin-right: 0.15em;
}

/* Rating chips composed: .filter-chip + .filter-chip-rating + .rating-<name>
   Inactive shows the rating color softly; active gets a stronger ring. */
.filter-chip-rating {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  border-color: transparent;
}

.filter-chip-rating:hover {
  border-color: var(--ink);
}

.filter-chip-rating.is-active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.filter-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.filter-clear {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-right: auto;
}

.filter-clear:hover {
  color: var(--ink);
}

.filter-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
}

.filter-sort select {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  padding: var(--space-1) var(--space-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
}

.filter-sort select:focus {
  border-color: var(--accent);
  outline: none;
}

.filter-count {
  color: var(--ink-muted);
  font-weight: 400;
}

.filter-empty {
  text-align: center;
  color: var(--ink-muted);
  padding: var(--space-12) 0;
}

/* ── Page header (list pages) ──────────────────────────── */
.page-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.page-header-count {
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 400;
}

/* ── Coffee list (used as gallery container) ───────────── */
.coffee-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: none;
}

.gallery-grid-item {
  margin: 0;
  list-style: none;
}

/* ── Gallery grid + cards (used on list, estate, roaster) */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-6);
}

.gallery-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 100%;
  transition: border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}

.gallery-card:has(.gallery-card-link:hover) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.gallery-card-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border-bottom: none;
}

.gallery-card-link:hover .gallery-card-title {
  color: var(--accent);
}

.gallery-card-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--accent-soft);
  overflow: hidden;
  flex-shrink: 0;
}

.gallery-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-card-photo-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4);
  background: var(--accent-soft);
  gap: var(--space-2);
}

.gallery-card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.gallery-card-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--ink);
  margin: 0 0 var(--space-1);
}

.gallery-card-byline {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin: 0;
  line-height: 1.4;
}

.gallery-card-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-4);
  margin-top: auto;
}

.gallery-card-foot .rating {
  margin-left: auto;
}

/* Tag-as-link (clickable tag chip) */
.tag-link {
  text-decoration: none;
  border-bottom: none;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease),
              color var(--duration) var(--ease);
}

.tag-link:hover {
  border-color: var(--accent);
  color: var(--ink);
}

/* ── Timeline cards ────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.timeline-month {
  margin-bottom: var(--space-12);
}

.timeline-month-label {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  position: sticky;
  top: 56px;
  z-index: 5;
  margin: 0 0 var(--space-6);
  padding: var(--space-3) 0;
  background: linear-gradient(to bottom,
    var(--bg) 0%,
    var(--bg) 75%,
    color-mix(in oklab, var(--bg) 0%, transparent) 100%);
}

.timeline-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.timeline-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-6);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}

.timeline-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ── Timeline card photo ───────────────────────────────── */
.timeline-card-photo {
  width: 200px;
  height: 200px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--accent-soft);
  flex-shrink: 0;
}

.timeline-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.timeline-card-photo img.dim {
  opacity: 0.85;
}

.timeline-card-photo-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4);
  background: var(--accent-soft);
  gap: var(--space-3);
}

.fallback-roaster {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--accent);
  word-break: break-word;
  hyphens: auto;
}

.fallback-origin {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

/* ── Timeline card body ────────────────────────────────── */
.timeline-card-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-2) 0;
}

.timeline-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.timeline-card-meta .method {
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
  font-weight: 400;
}

.timeline-card-meta .rating {
  margin-left: auto;
}

.timeline-card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 var(--space-1);
  line-height: 1.2;
}

.timeline-card:hover .timeline-card-title {
  color: var(--accent);
}

.timeline-card-byline {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin: 0 0 var(--space-3);
}

.timeline-card-excerpt {
  font-size: var(--text-sm);
  color: var(--ink);
  line-height: 1.55;
  margin: 0 0 var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Tags ──────────────────────────────────────────────── */
.timeline-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: auto;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  background: var(--bg);
  padding: 0.2em 0.6em;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.tag-country {
  font-size: var(--text-xs);
}

/* ── Coffee detail header ──────────────────────────────── */
.coffee-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--border);
}

.coffee-detail-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
  line-height: 1.1;
}

.coffee-detail-header .byline {
  font-size: var(--text-md);
  color: var(--ink-muted);
  margin: 0;
  font-family: var(--font-body);
}

.coffee-detail-header .byline a {
  color: var(--ink-muted);
}

.coffee-detail-header .byline a:hover {
  color: var(--accent);
}

.coffee-detail-header .rating {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: var(--space-2);
}

/* ── Coffee card image (bag photo in sidebar) ─────────── */
.coffee-card-image {
  margin: 0 0 var(--space-6);
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.coffee-card-image img {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Coffee detail grid ────────────────────────────────── */
.coffee-detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: var(--space-12);
  align-items: start;
}

.coffee-detail-aside {
  position: sticky;
  top: calc(var(--space-16) + var(--space-2));
  max-height: calc(100vh - var(--space-16) - var(--space-4));
  overflow-y: auto;
  padding-right: var(--space-3);
  /* Hide scrollbar by default; show on hover */
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
}

.coffee-detail-main {
  min-width: 0;  /* allow shrink in grid */
}

.aside-block {
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.aside-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.aside-block h3 {
  margin-top: 0;
  margin-bottom: var(--space-3);
}

.aside-block.aside-prose {
  font-size: var(--text-sm);
  line-height: 1.6;
}

.aside-block.aside-prose p {
  margin-bottom: var(--space-3);
}

.aside-block.aside-prose p:last-child {
  margin-bottom: 0;
}

.main-block {
  margin-bottom: var(--space-12);
}

.main-block:last-child {
  margin-bottom: 0;
}

.main-block > h3:first-child {
  margin-top: 0;
}

/* ── Definition-list metadata ──────────────────────────── */
.meta-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-6);
  margin: 0;
  font-size: var(--text-sm);
}

.meta-list dt {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--ink-muted);
  align-self: baseline;
  padding-top: 0.15em;
}

.meta-list dd {
  margin: 0;
  color: var(--ink);
}

/* ── Roaster notes blockquote ──────────────────────────── */
.roaster-notes {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-style: italic;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink);
}

/* ── Entity detail (estates, roasters) ─────────────────── */
.entity-detail-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-6);
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--border);
}

.entity-detail-header-text {
  min-width: 0;
}

.entity-detail-logo {
  flex: 0 0 auto;
  width: 120px;
}

.entity-detail-logo img {
  display: block;
  max-width: 100%;
  max-height: 96px;
  width: auto;
  height: auto;
}

.entity-eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0 0 var(--space-2);
}

.entity-detail-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
  line-height: 1.1;
}

.entity-detail-header .byline {
  font-size: var(--text-md);
  color: var(--ink-muted);
  margin: 0;
}

.entity-detail-grid {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: var(--space-12);
  align-items: start;
}

.entity-detail-aside {
  position: sticky;
  top: calc(var(--space-16) + var(--space-2));
  max-height: calc(100vh - var(--space-16) - var(--space-4));
  overflow-y: auto;
  padding-right: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
}

.entity-detail-main {
  min-width: 0;
}

/* ── Legacy meta-table (other detail pages still use it) ── */
.meta-table {
  font-size: var(--text-sm);
  margin-bottom: var(--space-8);
}

.meta-table th, .meta-table td {
  border-bottom: 1px solid var(--border);
}

.meta-table td:first-child {
  font-weight: 600;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  width: 1%;
  padding-right: var(--space-6);
}

/* ── Photos ────────────────────────────────────────────── */
.photos {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.photos img {
  max-height: 320px;
  width: auto;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ── Entity grid + cards (estates, roasters lists) ─────── */
.entity-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
  max-width: none;
}

.entity-grid li {
  margin: 0;
  list-style: none;
}

.entity-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  height: 100%;
  transition: border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}

.entity-card:has(.entity-card-link:hover) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.entity-card-link {
  display: block;
  padding: var(--space-6) var(--space-5, 1.25rem) var(--space-4);
  text-decoration: none;
  border-bottom: none;
  color: inherit;
  flex: 1;
}

.entity-card-flag {
  display: block;
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: var(--space-3);
}

.entity-card-logo {
  width: 100%;
  height: 64px;
  display: flex;
  align-items: center;
  margin-bottom: var(--space-4);
}

.entity-card-logo img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.entity-card-name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 var(--space-1);
}

.entity-card-link:hover .entity-card-name {
  color: var(--accent);
}

.entity-card-byline {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin: 0;
  line-height: 1.4;
}

.entity-card-producer {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  font-style: italic;
  margin: var(--space-2) 0 0;
  line-height: 1.4;
}

.entity-card-foot {
  padding: var(--space-3) var(--space-5, 1.25rem);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.entity-card-count {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
}

/* ── Tasting notes within coffee detail ────────────────── */
.tasting-note {
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--border);
}

.tasting-note:last-child {
  border-bottom: none;
}

.tasting-note h4 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: var(--space-3);
}

/* ── Section headings inside detail pages ─────────────── */
main h3 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}

/* ── Prose containers (markdown body in reference pages) ── */
.prose h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}

.prose h3 {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

.prose ul {
  max-width: var(--prose-max);
}

/* ── Back-link ─────────────────────────────────────────── */
.back-link {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-bottom: var(--space-6);
  border-bottom: none;
}

.back-link:hover {
  color: var(--accent);
}

/* ── Purchases list ────────────────────────────────────── */
.purchases {
  font-size: var(--text-sm);
}

/* ── Filter helper ─────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 960px) {
  .coffee-detail-grid,
  .entity-detail-grid {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .coffee-detail-aside,
  .entity-detail-aside {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .aside-block:last-child {
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-6);
  }
}

@media (max-width: 720px) {
  main {
    padding: var(--space-8) var(--space-4) var(--space-12);
  }

  header .container {
    gap: var(--space-3);
  }

  header nav ul {
    gap: var(--space-4);
  }

  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }

  .coffee-detail-header,
  .entity-detail-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  .coffee-detail-header h1,
  .entity-detail-header h1 {
    font-size: var(--text-xl);
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  .filter-label {
    padding-top: 0;
  }

  .timeline-card {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .timeline-card-photo {
    width: 100%;
    height: 220px;
  }
}
