/* ── COFFEE PAGE ── */
:root {
  /* Bean stages, in the order coffee goes through them: cherry, green bean, yellowing, first crack, dark roast. */
  --bean-sealed: #cf2f3f;
  --bean-fresh: #7fa35a;
  --bean-open: #d1a23f;
  --bean-half: #9a5f2c;
  --bean-last: #3a2413;
  --bean-stem: #4f7a3a;
  /* Tasting-note colours */
  --flavor-red: #d63d55;
  --flavor-green: #3f8f4f;
  --flavor-orange: #d9660f;
  --flavor-yellow: #b38600;
  --flavor-purple: #7d4fc4;
  --flavor-brown: #8a5a2b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bean-sealed: #ef5361;
    --bean-fresh: #9cc274;
    --bean-open: #e3bd5f;
    --bean-half: #c98a4e;
    --bean-last: #6b4526;
    --bean-stem: #8fbf6e;
    --flavor-red: #ff7a8f;
    --flavor-green: #7fce8a;
    --flavor-orange: #ff9a4d;
    --flavor-yellow: #f0c84a;
    --flavor-purple: #b594f5;
    --flavor-brown: #e2b07a;
  }
}

:root[data-theme="dark"] {
  --bean-sealed: #ef5361;
  --bean-fresh: #9cc274;
  --bean-open: #e3bd5f;
  --bean-half: #c98a4e;
  --bean-last: #6b4526;
  --bean-stem: #8fbf6e;
  --flavor-red: #ff7a8f;
  --flavor-green: #7fce8a;
  --flavor-orange: #ff9a4d;
  --flavor-yellow: #f0c84a;
  --flavor-purple: #b594f5;
  --flavor-brown: #e2b07a;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A coffee bean: an oval with a crease down the middle. */
.bean-dot {
  flex: none;
  display: inline-block;
  width: 9px;
  height: 12px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 44%, rgba(0, 0, 0, .35) 44% 56%, transparent 56%),
    var(--bean-open);
  transform: rotate(28deg);
}

.bean-fresh { background-color: var(--bean-fresh); }
.bean-open { background-color: var(--bean-open); }
.bean-half { background-color: var(--bean-half); }
.bean-last { background-color: var(--bean-last); }

/* A sealed bag is still a cherry: round, red, with a stem. */
.bean-sealed {
  position: relative;
  width: 11px;
  height: 11px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .45) 0 14%, transparent 16%), var(--bean-sealed);
  transform: none;
}

.bean-sealed::after {
  content: "";
  position: absolute;
  left: 5px;
  top: -4px;
  width: 1.5px;
  height: 5px;
  border-radius: 1px;
  background: var(--bean-stem);
  transform: rotate(24deg);
  transform-origin: bottom;
}

/* Home page: the coffee pill sits beside the "Latest" pill in the hero. */
.hero-pills { display: flex; flex-wrap: wrap; gap: 10px; }

.hero-pills .latest { align-self: auto; }

.cup-pill { gap: 12px; }

.cup-pill .latest-label { white-space: nowrap; }

.cup-beans { display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }

.cup-bean { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }

/* Hero */
.cup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 64px;
  align-items: center;
  padding: 72px 0 96px;
}

.cup .label { margin-bottom: 16px; font-weight: 500; }

/* The bags I have right now */
.bags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 44px; }

.bags[hidden] { display: none; }

.bag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: 500 14px var(--font);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.bag:hover, .bag.hop { color: var(--text); border-color: var(--muted); }

.bag[aria-pressed="true"] { color: var(--text); border-color: var(--text); }

.bag-stage { font-weight: 400; color: var(--muted); }

/* The flavour-poster idea in the site's own type: the tasting notes are the headline. */
.cup-lead { color: var(--muted); font-size: 15px; margin-bottom: 12px; }

.cup-taste {
  font-size: clamp(44px, 7vw, 88px);
  line-height: .98;
  letter-spacing: -0.04em;
  font-weight: 600;
  text-wrap: balance;
  margin-bottom: 36px;
}

/* --flavor lets the history rows reuse the same colour, but only while in focus (see below). */
.flavor-red { --flavor: var(--flavor-red); color: var(--flavor); }
.flavor-green { --flavor: var(--flavor-green); color: var(--flavor); }
.flavor-orange { --flavor: var(--flavor-orange); color: var(--flavor); }
.flavor-yellow { --flavor: var(--flavor-yellow); color: var(--flavor); }
.flavor-purple { --flavor: var(--flavor-purple); color: var(--flavor); }
.flavor-brown { --flavor: var(--flavor-brown); color: var(--flavor); }

.cup-name { font-size: 20px; margin-bottom: 16px; }

.cup-name span { margin-left: 12px; color: var(--muted); font-size: 15px; }

.cup-facts { max-width: 520px; }

.cup-facts div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.cup-facts div:first-child { border-top: 1px solid var(--line); }

.cup-facts dt { color: var(--muted); font-size: 14px; }

/* The details settle in on load and again each time a different bag is chosen. */
.swap > *, .bloom-wrap { animation: settle .5s cubic-bezier(.2, .7, .2, 1) both; }

.swap > :nth-child(2) { animation-delay: .05s; }

.swap > :nth-child(3) { animation-delay: .12s; }

.swap > :nth-child(4) { animation-delay: .18s; }

.bloom-wrap { animation-delay: .2s; }

@keyframes settle { from { opacity: 0; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
  .swap > *, .bloom-wrap { animation: none; }
}

/* The bloom: a top-down pour-over drawn on a canvas by js/bloom.js */
/* Pinned to the top of its column, level with the tasting notes, so swapping bags
   (which changes the height of the text column) never moves it. */
.bloom-wrap { width: 100%; max-width: 320px; justify-self: center; align-self: start; margin-top: 150px; text-align: center; }

.bloom {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #e9dcc4;
  /* just the paper: a hairline so its edge reads on a white page */
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
  cursor: crosshair;
  touch-action: pan-y;
}

.bloom-wrap figcaption { margin-top: 30px; color: var(--muted); font-size: 13px; opacity: .6; }

.bloom-touch { display: none; }

@media (hover: none) {
  .bloom-hover { display: none; }
  .bloom-touch { display: inline; }
}

/* Pick my next cup */
.pick-row { margin-top: 28px; }

.pick {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--text);
  font: 500 14px var(--font);
  cursor: pointer;
  transition: border-color .15s;
}

.pick:hover { border-color: var(--muted); }

.pick:disabled { color: var(--muted); cursor: default; }

.pick[hidden] { display: none; }

/* Next up: a shelf of bags I plan to try. Each tile is a bag seen front-on, with a crimped top. */
.shelf[hidden] { display: none; }

.shelf-lead { color: var(--muted); font-size: 15px; margin: -8px 0 28px; }

.shelf-list {
  list-style: none;
  display: grid;
  /* Any number of bags: columns wrap to fit, and each bag is only as tall as what it lists. */
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-items: start;
  gap: 14px;
  padding-bottom: 48px;
}

/* The shelf and the history are one run of bags, so the line between them gets half the usual section gap. */
.shelf:not([hidden]) + .history { padding-top: 48px; }

.shelf-bag {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 26px 16px 18px;
  border: 1px solid var(--line);
  border-radius: 4px 4px 14px 14px;
  font-size: 14px;
  color: var(--muted);
}

/* the crimp: a stitched seam across the top of the bag */
.shelf-bag::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 10px;
  border-top: 2px dotted var(--line);
}

.shelf-roaster { font-weight: 600; color: var(--text-body); }

.shelf-name { font-size: 16px; line-height: 1.3; color: var(--text); margin-bottom: 4px; }

.shelf-notes { margin-top: 6px; font-family: var(--serif); font-style: italic; font-size: 16px; }

@media (max-width: 720px) {
  .shelf-list { grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 40px; }
  .shelf:not([hidden]) + .history { padding-top: 40px; }
  .shelf-bag { padding: 24px 12px 14px; font-size: 13px; }
  .shelf-name { font-size: 15px; }
}

@media (max-width: 340px) {
  .shelf-list { grid-template-columns: 1fr; }
}

/* History */
.history { padding-bottom: 120px; }

.history[hidden] { display: none; }

/* The roaster is the brand: give it weight so each row reads roaster, then coffee. */
.history .log-tag { font-weight: 600; color: var(--text-body); }

.past { display: flex; flex-direction: column; gap: 2px; }

.past-name { font-size: 16px; color: var(--text); }

.past-rating { margin-left: 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.past-notes { font-size: 14px; }

/* The row being read (js/coffee.js picks it as the page scrolls) shows its notes in flavour colours,
   like the headline up top, and they fade back to grey as it moves on. Notes with no colour stay grey. */
.past-notes > span { color: var(--muted); transition: color .6s ease; }

.log li.in-focus .past-notes > span { color: var(--flavor, var(--muted)); transition-duration: .25s; }

@media (prefers-reduced-motion: reduce) {
  .past-notes > span { transition: none; }
}

@media (max-width: 720px) {
  .history { padding-bottom: 96px; }
  .log .past { grid-column: 1 / -1; }
  /* Undated rows have an empty <time>; its column and gap pushed the roaster in from the left. */
  .history .log time:empty { display: none; }
  .cup { grid-template-columns: 1fr; gap: 40px; padding: 32px 0 72px; }
  .bloom-wrap { margin-top: 0; }
  .bloom-wrap { max-width: 200px; order: -1; justify-self: start; margin: 11px; }
  .bags { margin-bottom: 32px; }
}

/* On a phone the pill becomes two rows: its name, then the beans. */
@media (max-width: 480px) {
  .cup-pill { flex-wrap: wrap; gap: 6px 12px; padding: 10px 14px; border-radius: 16px; }
  .cup-pill .cup-beans { order: 3; flex-basis: 100%; }
  .cup-pill > :last-child { margin-left: auto; }
}
