/* Today's bake page. Shared pieces (header, footer, buttons) are in styles.css */

:root {
  --tint-teal: color-mix(in srgb, var(--brand-teal) 55%, var(--surface));
  --tint-rose: color-mix(in srgb, var(--brand-rose) 55%, var(--surface));
  --tint-sand: color-mix(in srgb, #d9c3a5 60%, var(--surface));
  --tint-sage: color-mix(in srgb, #a9bfa2 60%, var(--surface));
}

/* ---------- Header extras ---------- */

.bag-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent-2);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
}

/* ---------- Hero + board ---------- */

.today-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: end;
  gap: clamp(32px, 6vw, 80px);
  padding: clamp(24px, 5vh, 56px) 0 clamp(32px, 5vh, 48px);
}

.today-hero h1 {
  font-size: clamp(2.5rem, 5.4vw, 4.75rem);
}

.today-intro {
  max-width: 30rem;
  margin: 24px 0 0;
  color: var(--muted);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
}

.board > div {
  padding: 16px 16px 18px 0;
}

.board > div + div {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.board dt {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.board dd {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 2.2vw, 1.75rem);
  line-height: 1.2;
}

.board .board-sub {
  margin-top: 4px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--muted);
}

.board .is-urgent {
  color: var(--accent-2);
}

.closed-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 24px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 0.9375rem;
}

.closed-note i {
  font-size: 20px;
  color: var(--accent-2);
}

/* ---------- Menu list ---------- */

.menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: grid;
  grid-template-columns: 48px 200px minmax(0, 1fr) 240px;
  grid-template-areas: "num media info buy";
  gap: 32px;
  align-items: start;
  padding: 32px 0;
  border-bottom: 1px solid var(--line);
}

.item-num {
  grid-area: num;
  padding-top: 4px;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--accent-2);
}

.item-media {
  grid-area: media;
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 18px;
  background: var(--tint-sand);
}

.item-media.tint-teal { background: var(--tint-teal); }
.item-media.tint-rose { background: var(--tint-rose); }
.item-media.tint-sand { background: var(--tint-sand); }
.item-media.tint-sage { background: var(--tint-sage); }

.item-media .photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-media .swirl {
  width: 48%;
  opacity: 0.9;
}

.item-flag {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.item-info {
  grid-area: info;
  padding-top: 2px;
}

.item-meta {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.item h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  line-height: 1.15;
}

.item-desc {
  max-width: 30rem;
  margin: 10px 0 0;
  color: var(--muted);
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.item-tags li {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--accent);
}

.item-buy {
  grid-area: buy;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  text-align: right;
}

.price {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1;
}

.price small {
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-right: 4px;
}

/* One pip per piece baked; filled = still available */
.pips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
  max-width: 180px;
}

.pips span {
  width: 6px;
  height: 14px;
  border-radius: 3px;
  background: var(--line);
}

.pips .on {
  background: var(--accent);
}

.stock-label {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.stock-label.is-low {
  color: var(--accent-2);
  font-weight: 500;
}

.buy-control {
  margin-top: 6px;
}

.btn-add {
  padding: 12px 22px;
}

.btn-add:disabled {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ink);
  border-radius: 999px;
}

.stepper button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
}

.stepper button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stepper output {
  min-width: 24px;
  text-align: center;
  font-weight: 500;
}

.stepper.is-small button {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

/* Sold out: faded row, struck-through price and a stamp over the picture */
.item.is-soldout .item-media {
  background: var(--surface);
}

.item.is-soldout .item-media img {
  filter: grayscale(1);
  opacity: 0.35;
}

.item.is-soldout .item-info,
.item.is-soldout .price {
  opacity: 0.5;
}

.item.is-soldout .price {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.soldout-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 58%;
  aspect-ratio: 1;
  padding: 8px;
  border: 1.5px solid var(--accent-2);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--bg) 85%, transparent), inset 0 0 0 5px var(--accent-2);
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -50%) rotate(-12deg);
}

.stock-label.is-soldout {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent-2);
}

/* ---------- Tomorrow ---------- */

.tomorrow {
  padding: 48px 0 56px;
}

.tomorrow-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.2vw, 1.625rem);
  font-weight: 300;
}

.tomorrow-list li:not(:last-child)::after {
  content: "/";
  margin-left: 28px;
  color: var(--muted);
  opacity: 0.4;
}

/* ---------- Floating bag bar ---------- */

.bag-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font: inherit;
  font-size: 0.9375rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%);
  cursor: pointer;
  animation: bar-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.bag-bar-total {
  padding-left: 18px;
  border-left: 1px solid color-mix(in srgb, var(--btn-ink) 30%, transparent);
  font-weight: 500;
}

@keyframes bar-in {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }
}

/* ---------- Bag drawer ---------- */

.bag {
  width: min(440px, 100vw);
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--ink);
}

.bag::backdrop {
  background: rgba(20, 18, 17, 0.45);
}

.bag[open] {
  animation: drawer-in 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes drawer-in {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
}

.bag-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.bag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.bag-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.75rem;
}

.bag-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 24px 24px;
}

.bag-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bag-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.bag-item .item-media {
  grid-area: auto;
  border-radius: 12px;
}

.bag-item h3 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.25;
}

.bag-item p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.bag-item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.bag-item-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.remove-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.remove-button:hover {
  background: var(--surface);
  color: var(--accent-2);
}

.bag-line-total {
  font-size: 0.9375rem;
  font-weight: 500;
}

.bag-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}

.fulfilment {
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}

.fulfilment legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.9375rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.segmented input:checked + span {
  background: var(--btn-bg);
  color: var(--btn-ink);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.fields {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 0.8125rem;
  color: var(--muted);
}

.field em {
  font-style: normal;
  opacity: 0.7;
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  resize: vertical;
  transition: border-color 0.2s ease;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--accent-2);
}

.totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
}

.totals dt {
  color: var(--muted);
}

.totals dd {
  margin: 0;
  text-align: right;
}

.totals .grand {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 1.375rem;
  color: var(--ink);
}

.bag-foot {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--line);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-block:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-error {
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--accent-2);
}

.bag-fineprint {
  margin: 10px 0 0;
  font-size: 0.75rem;
  text-align: center;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .bag-bar,
  .bag[open] {
    animation: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .today-hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .item {
    grid-template-columns: 140px minmax(0, 1fr);
    grid-template-areas:
      "media info"
      "media buy";
    gap: 16px 24px;
  }

  .item-num {
    display: none;
  }

  .item-buy {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    text-align: left;
  }

  .pips {
    display: none;
  }

  .buy-control {
    margin-top: 0;
  }
}

@media (max-width: 560px) {
  .board {
    grid-template-columns: 1fr;
  }

  .board > div,
  .board > div + div {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 0 12px;
    padding: 12px 0;
    border-left: 0;
  }

  .board > div + div {
    border-top: 1px solid var(--line);
  }

  .board dd {
    margin: 0;
    text-align: right;
  }

  .board .board-sub {
    grid-column: 1 / -1;
    text-align: left;
  }

  .soldout-stamp {
    width: 72%;
    padding: 4px;
    font-size: 0.5625rem;
    letter-spacing: 0.1em;
  }

  .item {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-areas:
      "media info"
      "buy buy";
    padding: 24px 0;
  }

  .item-media {
    border-radius: 14px;
  }

  .item-flag {
    top: 6px;
    left: 6px;
    padding: 2px 7px;
    font-size: 0.5625rem;
  }

  .item h3 {
    font-size: 1.375rem;
  }

  .item-desc {
    font-size: 0.9375rem;
  }

  .bag-bar {
    left: 16px;
    right: 16px;
    justify-content: space-between;
    transform: none;
  }

  @keyframes bar-in {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
  }
}
