/* ==========================================================================
   Steep — grind guide

   The "Grind guide" button beside GRIND on the product page, and the dialog
   it opens: five cards in a row on a desktop, a bottom sheet of five rows on a
   phone. Markup in inc/class-steep-grind-guide.php, behaviour in
   assets/js/grind-guide.js. Loaded after product.css on product pages.
   ========================================================================== */

/* --- the button beside the label ------------------------------------------ */

.single-product .steep-grind__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* The label moved into the head row; product.css styles it only as a direct
   child of .steep-grind, so the same look is given here. */
.single-product .steep-grind__head > label {
  display: block;
  margin: 0;
  font-family: var(--steep-font);
  font-size: max(1rem, calc(24 * var(--u)));
  font-weight: 400;
  line-height: 1.42;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--steep-espresso);
}

.single-product button.steep-guide-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #4B2C20;
  font-family: var(--steep-font);
  font-size: max(0.85rem, calc(16 * var(--u)));
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.single-product button.steep-guide-trigger span {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.single-product button.steep-guide-trigger svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.single-product button.steep-guide-trigger:hover {
  background: none;
  color: var(--steep-terracotta);
}

.single-product button.steep-guide-trigger:focus-visible {
  outline: 2px solid var(--steep-terracotta);
  outline-offset: 3px;
}

/* The guide says what the one-line hint said, and more. */
.single-product .steep-grind.has-guide .steep-grind__hint { display: none; }

/* Page behind an open guide does not scroll. */
html.steep-guide-open,
html.steep-guide-open body {
  overflow: hidden;
}

/* --- the dialog: shared ---------------------------------------------------- */

dialog.steep-guide {
  --guide-ink: #19110C;
  --guide-brown: #4B2C20;
  --guide-grey: #8A7C71;
  --guide-line: #E6D9C8;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--guide-ink);
  font-family: var(--steep-font);
  overflow: visible;
}

dialog.steep-guide::backdrop {
  background: rgba(25, 17, 12, 0.55);
}

.steep-guide__sheet {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  background: #FDFAF6;
  transition: transform 220ms ease;
}

.steep-guide__head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.steep-guide__handle { display: none; }

.steep-guide__eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steep-terracotta);
}

dialog.steep-guide .steep-guide__title {
  margin: 0.25rem 0 0;
  font-family: var(--steep-font);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  color: var(--guide-ink);
}

.steep-guide__lede {
  margin: 0.35rem 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--guide-grey);
}

dialog.steep-guide button.steep-guide__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--guide-line);
  border-radius: 50%;
  background: #fff;
  color: var(--guide-brown);
  cursor: pointer;
}

dialog.steep-guide button.steep-guide__close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

dialog.steep-guide button.steep-guide__close:hover {
  border-color: var(--guide-brown);
  background: #fff;
  color: var(--guide-brown);
}

.steep-guide__scale {
  position: relative;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--guide-grey);
}

.steep-guide__scale::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 4.5rem;
  right: 3.5rem;
  height: 1px;
  background: var(--guide-grey);
}

/* Each grind is one button. */
dialog.steep-guide button.steep-guide__option {
  box-sizing: border-box;
  display: flex;
  min-height: 0;
  margin: 0;
  border: 1px solid var(--guide-line);
  background: #fff;
  color: var(--guide-ink);
  font-family: var(--steep-font);
  font-weight: 400;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

dialog.steep-guide button.steep-guide__option:hover {
  border-color: var(--guide-brown);
  background: #fff;
  color: var(--guide-ink);
}

dialog.steep-guide button.steep-guide__option.is-selected {
  border-color: var(--guide-brown);
  box-shadow: inset 0 0 0 1px var(--guide-brown);
}

dialog.steep-guide button.steep-guide__option:focus-visible {
  outline: 2px solid var(--steep-terracotta);
  outline-offset: 2px;
}

.steep-guide__texture { flex: none; display: block; }

.steep-guide__text { display: flex; flex-direction: column; min-width: 0; }

.steep-guide__name {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--guide-ink);
}

.steep-guide__badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--guide-brown);
  color: #fff;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.4;
  vertical-align: 2px;
}

.steep-guide__feel {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--guide-grey);
}

.steep-guide__kit { display: flex; }

.steep-guide__brewer {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 12px;
  line-height: 1.25;
  color: var(--guide-brown);
}

.steep-guide__brewer svg {
  flex: none;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--guide-brown);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.steep-guide__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.steep-guide__note {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--guide-grey);
}

dialog.steep-guide button.steep-guide__use {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  margin: 0;
  padding: 0 1.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--guide-brown);
  color: #fff;
  font-family: var(--steep-font);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  cursor: pointer;
}

dialog.steep-guide button.steep-guide__use:hover {
  background: var(--steep-espresso);
  color: #fff;
}

dialog.steep-guide button.steep-guide__use:focus-visible {
  outline: 2px solid var(--steep-terracotta);
  outline-offset: 3px;
}

/* --- desktop and tablet: a centred panel of five cards ---------------------- */

@media (min-width: 768px) {
  dialog.steep-guide {
    width: min(1120px, calc(100vw - 3rem));
    max-width: none;
    max-height: calc(100vh - 3rem);
    margin: auto;
  }

  dialog.steep-guide[open] .steep-guide__sheet {
    animation: steep-guide-pop 200ms ease-out;
  }

  .steep-guide__sheet {
    padding: 2rem 2rem 1.75rem;
    border-radius: 16px;
  }

  dialog.steep-guide .steep-guide__title { font-size: 28px; }

  .steep-guide__scale { margin: 1.5rem 0.25rem 0.75rem; }

  .steep-guide__options {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    overflow-y: auto;
    padding: 2px;
  }

  dialog.steep-guide button.steep-guide__option {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 12px 16px;
    border-radius: 12px;
  }

  .steep-guide__texture { width: 100%; height: 64px; }

  .steep-guide__text { margin-top: 8px; }

  .steep-guide__name,
  .steep-guide__feel { text-align: center; }

  .steep-guide__badge {
    display: table;
    margin: 4px auto 0;
  }

  .steep-guide__kit {
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--guide-line);
  }

  .steep-guide__foot { margin-top: 1.25rem; }
}

/* --- phones: a bottom sheet of rows ------------------------------------------ */

@media (max-width: 767px) {
  dialog.steep-guide {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    margin: auto 0 0;
  }

  dialog.steep-guide[open] .steep-guide__sheet {
    animation: steep-guide-rise 240ms ease-out;
  }

  .steep-guide__sheet {
    border-radius: 18px 18px 0 0;
    background: #fff;
  }

  .steep-guide__head {
    padding: 1.35rem 1rem 0.85rem;
    border-bottom: 1px solid var(--guide-line);
    touch-action: none;
  }

  .steep-guide__handle {
    display: block;
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: #D3D1C7;
  }

  dialog.steep-guide .steep-guide__title { font-size: 18px; }

  .steep-guide__lede { display: none; }

  .steep-guide__scale { display: none; }

  .steep-guide__options {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  dialog.steep-guide button.steep-guide__option {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 1rem;
    border: 0;
    border-bottom: 1px solid var(--guide-line);
    border-radius: 0;
  }

  dialog.steep-guide button.steep-guide__option:hover { border-color: var(--guide-line); }

  dialog.steep-guide button.steep-guide__option.is-selected {
    border-color: var(--guide-line);
    background: #F9EEE2;
    box-shadow: inset 4px 0 0 var(--guide-brown);
  }

  .steep-guide__texture {
    width: 56px;
    height: 56px;
    padding: 6px;
    border-radius: 10px;
    background: #FDFAF6;
    box-sizing: border-box;
  }

  .steep-guide__kit {
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 6px;
  }

  .steep-guide__brewer svg { width: 24px; height: 24px; }

  .steep-guide__foot {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.75rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--guide-line);
    background: #fff;
  }

  .steep-guide__note { text-align: center; font-size: 12px; }

  dialog.steep-guide button.steep-guide__use { width: 100%; }
}

@keyframes steep-guide-rise {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes steep-guide-pop {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  dialog.steep-guide[open] .steep-guide__sheet { animation: none; }
  .steep-guide__sheet { transition: none; }
}
