/* ============================================
   EMBER COFFEE - Cupping card generator
   Scoped styles; base tokens come from ../style.css
   ============================================ */

/* Accessibility */
.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;
}

/* Push nav off the top */
.cupping-page {
  padding-top: 4.5rem;
  background: var(--cream);
  min-height: 100vh;
}

/* ===== INTRO ===== */
.cup-intro {
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(1.5rem, 3vw, 2.5rem);
}

.cup-intro__inner {
  max-width: 780px;
}

.cup-intro__label {
  color: var(--deep);
  margin-bottom: 1rem;
}

.cup-intro__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: var(--darkest);
  margin-bottom: 1.25rem;
}

.cup-intro__title em {
  font-style: italic;
  color: var(--deep);
}

.cup-intro__lede {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  line-height: 1.6;
  color: var(--text-body);
  max-width: 58ch;
}

/* ===== BUILDER GRID ===== */
.cup-builder {
  padding-bottom: clamp(4rem, 10vw, 7rem);
}

.cup-builder__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}

@media (max-width: 960px) {
  .cup-builder__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===== SECTIONS ===== */
.cup-section {
  background: var(--linen);
  border: 1px solid rgba(176, 74, 46, 0.08);
  padding: clamp(1.25rem, 2.5vw, 2rem);
  margin-bottom: 1.5rem;
  position: relative;
}

.cup-section__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.cup-section__label {
  color: var(--deep);
  font-size: 0.72rem;
}

.cup-section__hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.cup-counter {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--deep);
  background: rgba(176, 74, 46, 0.08);
  padding: 0.3rem 0.6rem;
  border-radius: 0;
}

.cup-counter.is-full {
  background: var(--deep);
  color: var(--cream);
}

/* ===== WHEEL ===== */
.cup-wheel-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.cup-wheel {
  width: 100%;
  max-width: 460px;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

.cup-wheel .family-label {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: var(--text-muted);
  pointer-events: none;
}

.cup-wheel .note-label {
  font-family: 'Outfit', sans-serif;
  font-size: 8.5px;
  font-weight: 500;
  fill: var(--text-dark);
  pointer-events: none;
  letter-spacing: 0.01em;
}

.cup-wheel .petal {
  cursor: pointer;
  transition: transform 0.35s var(--ease-out), filter 0.25s var(--ease);
  transform-origin: center;
  transform-box: fill-box;
  stroke: rgba(74, 30, 18, 0.08);
  stroke-width: 0.6;
}

.cup-wheel .petal:hover {
  filter: brightness(1.07) saturate(1.1);
}

.cup-wheel .petal.is-picked {
  fill: var(--deep) !important;
  filter: drop-shadow(0 2px 10px rgba(176, 74, 46, 0.45));
}

.cup-wheel .petal.is-picked + .note-label,
.cup-wheel .petal.is-picked ~ .note-label {
  fill: var(--cream);
}

.cup-wheel .note-label.is-picked-label {
  fill: var(--cream) !important;
  font-weight: 600;
}

.cup-wheel .hub {
  fill: var(--cream);
  stroke: var(--deep);
  stroke-width: 1.2;
}

.cup-wheel .hub-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  font-style: italic;
  fill: var(--deep);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Chosen chips legend */
.cup-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  min-height: 2rem;
}

.cup-chips li {
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--cream);
  background: var(--deep);
  padding: 0.4rem 0.85rem;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  animation: cupChipIn 0.32s var(--ease-out);
}

.cup-chips li button {
  color: inherit;
  opacity: 0.75;
  padding: 0 0 0 0.15rem;
  line-height: 1;
  font-size: 1rem;
  cursor: pointer;
}

.cup-chips li button:hover {
  opacity: 1;
}

.cup-chips:empty::before {
  content: "Your notes appear here";
  display: inline-block;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  padding: 0.4rem 0;
}

@keyframes cupChipIn {
  from { opacity: 0; transform: translateY(6px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== VERDICT INPUT ===== */
.cup-verdict {
  width: 100%;
  min-height: 4.5rem;
  padding: 1rem 1.1rem;
  background: var(--cream);
  border: 1px solid rgba(176, 74, 46, 0.18);
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.15rem, 1.8vw, 1.35rem);
  font-style: italic;
  line-height: 1.35;
  color: var(--text-dark);
  resize: vertical;
  outline: none;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.cup-verdict:focus {
  border-color: var(--deep);
  box-shadow: 0 0 0 3px rgba(176, 74, 46, 0.15);
}

.cup-verdict::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* ===== ACTIONS ===== */
.cup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 1.25rem;
}

.cup-actions--inline {
  flex-direction: row;
  align-items: center;
  margin-top: 0;
}

.cup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.9rem 1.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
              border-color 0.25s var(--ease), transform 0.12s var(--ease);
}

.cup-btn:active {
  transform: translateY(1px);
}

.cup-btn svg {
  width: 16px;
  height: 16px;
}

.cup-btn--primary {
  background: var(--deep);
  color: var(--cream);
  border-color: var(--deep);
}

.cup-btn--primary:hover {
  background: var(--darkest);
  border-color: var(--darkest);
}

.cup-btn--primary:disabled {
  background: rgba(107, 45, 30, 0.25);
  border-color: transparent;
  color: rgba(251, 240, 225, 0.7);
  cursor: not-allowed;
}

.cup-btn--ghost {
  background: transparent;
  color: var(--deep);
  border-color: rgba(176, 74, 46, 0.3);
}

.cup-btn--ghost:hover {
  background: var(--deep);
  color: var(--cream);
  border-color: var(--deep);
}

.cup-share-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

/* ===== PREVIEW COLUMN ===== */
.cup-preview-col {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 960px) {
  .cup-preview-col {
    position: static;
  }
}

.cup-preview__label {
  color: var(--deep);
}

.cup-preview-frame {
  width: 100%;
  /* 1200 x 630 aspect, scaled down via SVG-style transform below */
  aspect-ratio: 1200 / 630;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(176, 74, 46, 0.12);
  box-shadow: 0 20px 60px -25px rgba(74, 30, 18, 0.35);
  background: var(--cream);
}

/* Card lives at its true 1200x630 size, then is scaled to fit the frame.
   This way html2canvas exports at full native res regardless of viewport. */
.cup-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 1200px;
  height: 630px;
  transform-origin: 0 0;
  /* Scale matched by JS via setCardScale() using ResizeObserver.
     CSS fallback using container queries would be possible, but JS is
     the reliable path for html2canvas to capture 1:1 native. */

  background:
    radial-gradient(ellipse at 20% 0%, rgba(241, 179, 142, 0.25) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(206, 107, 72, 0.22) 0%, transparent 60%),
    linear-gradient(180deg, #FBF0E1 0%, #F5E5CF 100%);

  color: var(--darkest);
  padding: 80px 90px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 32px;
  overflow: hidden;
  font-family: 'Outfit', 'Helvetica Neue', Arial, sans-serif;
}

.cup-card__paper {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.cup-card__stain {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0.22;
  mix-blend-mode: multiply;
}

/* layer order inside card */
.cup-card > :not(.cup-card__paper) {
  position: relative;
  z-index: 1;
}

/* Wordmark top-left */
.cup-card__mark {
  color: var(--deep);
}

.cup-card__mark svg {
  width: 180px;
  height: auto;
  display: block;
}

/* Chips row */
.cup-card__chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  align-content: flex-start;
}

.cup-card__chips li {
  font-family: 'Outfit', 'Helvetica Neue', Arial, sans-serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--darkest);
  background: rgba(251, 240, 225, 0.65);
  border: 1.5px solid var(--deep);
  padding: 14px 26px;
  border-radius: 0;
  white-space: nowrap;
}

.cup-card__chip-placeholder {
  background: transparent !important;
  border: 1.5px dashed rgba(176, 74, 46, 0.35) !important;
  color: var(--text-muted) !important;
  font-style: italic;
}

/* Ghosted empty-state chips - visible at 30% until user picks a note */
.cup-card__chips[data-ghost="true"] .cup-card__chip-ghost {
  opacity: 0.3;
  background: transparent;
  border: 1.5px dashed rgba(176, 74, 46, 0.5);
  color: var(--deep);
  transition: opacity 0.4s var(--ease-out);
}

.cup-card__chips:not([data-ghost="true"]) .cup-card__chip-ghost {
  opacity: 0;
}

/* Verdict: rendered as inline SVG so web font dependency is explicit
   and html2canvas uses SVG text rasterisation only.
   We include Cormorant via the <link> in head; however to guarantee a clean
   export even if the font hasn't loaded, we use font-family that falls back
   to Georgia and write the letters as <text> (not paths). If you need 100%
   guaranteed parity across machines, ship the font as woff2 self-hosted. */
.cup-card__verdict {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  padding: 0 40px;
}

.cup-card__verdict svg {
  width: 100%;
  height: 170px;
  display: block;
  overflow: visible;
}

/* Bottom rule + meta */
.cup-card__rule {
  height: 1px;
  background: linear-gradient(90deg,
    rgba(176, 74, 46, 0.3) 0%,
    rgba(176, 74, 46, 0.6) 50%,
    rgba(176, 74, 46, 0.3) 100%);
}

.cup-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Outfit', 'Helvetica Neue', Arial, sans-serif;
}

.cup-card__tag {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--deep);
}

.cup-card__url {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-dark);
}

/* ===== STICKY MOBILE SHARE ===== */
.cup-sticky {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  background: rgba(44, 24, 16, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(224, 138, 98, 0.25);
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-out);
}

.cup-sticky.is-visible {
  transform: translateY(0);
}

.cup-sticky__status {
  font-size: 0.8rem;
  color: var(--text-light-muted);
  flex: 1;
  min-width: 0;
}

.cup-sticky__btn {
  padding: 0.7rem 1.4rem;
  font-size: 0.75rem;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .cup-sticky {
    display: flex;
  }
  .cup-builder {
    padding-bottom: 6rem; /* room for sticky bar */
  }
  /* hide the inline share button on mobile; sticky takes over */
  .cup-preview-col .cup-actions {
    display: none;
  }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .cup-wheel .petal,
  .cup-btn,
  .cup-verdict,
  .cup-chips li {
    transition: none;
    animation: none;
  }
}

/* Flash animation when card exports */
.cup-preview-frame.is-flashing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cream);
  opacity: 0;
  animation: cupFlash 0.6s var(--ease-out);
  pointer-events: none;
}

@keyframes cupFlash {
  0%   { opacity: 0; }
  25%  { opacity: 0.8; }
  100% { opacity: 0; }
}

/* ===== TOAST (inline share-fallback snackbar) ===== */
.cup-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1200;
  max-width: 22rem;
  padding: 0.85rem 1.1rem;
  background: var(--deep);
  color: var(--cream);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.4;
  box-shadow: 0 14px 40px -18px rgba(74, 30, 18, 0.6);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.cup-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 700px) {
  .cup-toast {
    right: 1rem;
    left: 1rem;
    bottom: calc(4rem + env(safe-area-inset-bottom));
    max-width: none;
  }
}

/* Stronger picked-petal indicator for colour-impaired users */
.cup-wheel .petal.is-picked {
  filter: drop-shadow(0 0 6px rgba(43, 20, 12, 0.8))
          drop-shadow(0 2px 10px rgba(176, 74, 46, 0.5));
}
