/*
Theme Name:        Stacko
Theme URI:         https://www.stacko.co.uk/
Author:            Stacko
Description:       Custom theme for Stacko stackable crisps. Ports the original hand-built
                   design system (comic palette, flavour re-inking, chip pit) to WordPress,
                   with Elementor and WooCommerce support.
Version:           0.1.6
Requires at least: 6.6
Tested up to:      7.1
Requires PHP:      8.1
License:           Proprietary
Text Domain:       stacko
Tags:              e-commerce, custom-menu, custom-logo, full-width-template
*/

/*
 * The design system lives in assets/css/ (fonts.css, stacko.css and the page-specific sheets),
 * copied from the original static build. This file holds WordPress-only glue: admin bar offset,
 * core block alignment and Elementor/WooCommerce adjustments.
 */

/* Keep the sticky header and cart drawer below the WordPress admin bar when logged in. */
.admin-bar .hdr,
.admin-bar .cart { top: 32px; }
@media (max-width: 782px) {
  .admin-bar .hdr,
  .admin-bar .cart { top: 46px; }
}

/* WordPress core alignment classes used by the block editor and Elementor text widgets. */
.alignleft { float: left; margin: 0 1.5em 1em 0; }
.alignright { float: right; margin: 0 0 1em 1.5em; }
.aligncenter { display: block; margin-inline: auto; }
.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}


/*
 * Image sizing guard.
 * Elementor (`.elementor img`) and WooCommerce (`.woocommerce img`, where .woocommerce is on
 * <body>) both reset every image to `height:auto; max-width:100%` (and Elementor also strips
 * border/radius/shadow) with specificity 0,1,1 — beating the design system's single-class
 * image rules and blowing the cans up to their 1864px natural height. These selectors
 * (specificity 0,2,0+) restore the original sizes, values copied from the design CSS.
 */
:is(.elementor, .woocommerce, .woocommerce-page) .fhero__can { height: min(42vh, 440px); }
:is(.elementor, .woocommerce, .woocommerce-page) .taste__shot { height: min(58vh, 540px); }
:is(.elementor, .woocommerce, .woocommerce-page) .next__link img { height: clamp(80px, 12vh, 130px); }
:is(.elementor, .woocommerce, .woocommerce-page) .pit__can { height: clamp(220px, 40vh, 420px); }
/* The theme adds width/height attributes (no layout shift while loading); the design CSS sets
   width:auto on every can except this one, so the 656px attribute would otherwise win. */
.pit__can { width: auto; }
:is(.elementor, .woocommerce, .woocommerce-page) .mega__tile img { height: 118px; }
:is(.elementor, .woocommerce, .woocommerce-page) .ftr__cert,
:is(.elementor, .woocommerce, .woocommerce-page) .certrow img {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4);
}
:is(.elementor, .woocommerce, .woocommerce-page) .ftr__cert { height: 52px; }
:is(.elementor, .woocommerce, .woocommerce-page) .certrow img { height: 54px; }
.elementor .hero__can { height: min(62vh, 640px); }
.elementor .fan__can { height: clamp(190px, 34vh, 360px); }
.elementor .heat__can { height: min(52vh, 470px); }
@media (max-width: 960px) {
  .elementor .hero__can { height: min(46vh, 420px); }
}
@media (max-width: 760px) {
  .elementor .pit__can { height: clamp(130px, 26vh, 200px); }
}
@media (max-width: 640px) {
  :is(.woocommerce, .woocommerce-page) .pit__can { height: clamp(130px, 26vh, 200px); }
}

/*
 * Accessibility (WCAG 2.2 AA) adjustments — minimal, measured with tools/compare/a11y.js.
 * Small light text had opacity that dropped it under 4.5:1; Spicy Ramen orange and Onion &
 * Herbs green are under 4.5:1 behind white text, so those two use their own darker palette
 * tone (--flavor-dark) where white text sits on the flavour colour.
 */
.lineup .fan__num,
.lineup .fan__tag,
.next .next__meta small,
ul.products .stacko-card__num { opacity: .92; }
.buy__pack[aria-checked="true"] small { opacity: 1; }
:is([data-flavour="spicyRamen"], [data-flavour="onionHerbs"]) .buy__pack[aria-checked="true"],
:is([data-flavour="spicyRamen"], [data-flavour="onionHerbs"]) .acc__btn[aria-expanded="true"],
:is([data-flavour="spicyRamen"], [data-flavour="onionHerbs"]) .acc__btn:hover { background: var(--flavor-dark); }
/* Mini-cart remove link: 28px target (2.5.8) and readable on ink (WooCommerce paints it red). */
.cart .woocommerce-mini-cart-item a.remove {
  display: grid !important;
  place-items: center;
  width: 28px !important;
  height: 28px !important;
  top: 4px;
  right: 4px;
  color: var(--paper) !important;
  font-size: 22px;
  border-radius: 0;
}
.cart .woocommerce-mini-cart-item a.remove:hover,
.cart .woocommerce-mini-cart-item a.remove:focus-visible { color: var(--ink) !important; background: var(--pop) !important; }

/*
 * Hero badge on phones. The original positions the starburst against the whole hero
 * (top/right %), so under 600px wide it lands on the kicker and title. On wide screens the
 * stage is display:contents (layout identical to the original); on phones the badge is
 * anchored to the can's shoulder instead.
 */
.fhero__stage { display: contents; }
@media (max-width: 640px) {
  .fhero__stage { display: block; position: relative; width: max-content; margin-inline: auto; }
  .fhero .fhero__stage .fhero__badge { top: 4%; right: auto; left: calc(100% + 14px); } /* 14px clears the 10° rotation */
}

/* Footer credit — same small type as the bottom row; ~6:1 contrast on ink (WCAG AA). */
.ftr__credit {
  margin-top: -14px;
  padding-bottom: 22px;
  font-size: 11px;
  letter-spacing: .06em;
  line-height: 1.7;
  text-align: center;
  color: rgba(255, 255, 255, .6);
}
.ftr__credit a {
  color: rgba(255, 255, 255, .85);
  border-bottom: 1px solid rgba(255, 230, 0, .5);
}
.ftr__credit a:hover,
.ftr__credit a:focus-visible { color: var(--pop); border-bottom-color: var(--pop); }

/* Header cart: icon button + permanent count badge (comic style: pop yellow, ink rim, hard shadow). */
.cartbtn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px; /* 44px touch target (WCAG 2.5.5). */
  color: var(--paper);
  border: 2px solid var(--paper);
  background: var(--ink);
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.cartbtn:hover,
.cartbtn:focus-visible { background: var(--pop); color: var(--ink); border-color: var(--ink); }
.cartbtn:active { transform: translate(2px, 2px); }
.cartbtn svg { width: 22px; height: 22px; }
.cartbtn__badge {
  position: absolute;
  top: -9px;
  right: -9px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  font-family: var(--body);
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  color: var(--ink);
  background: var(--pop);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .35);
  pointer-events: none;
}
.cartbtn__badge.is-bump { animation: cartBump .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes cartBump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .cartbtn__badge.is-bump { animation: none; } }

/* Mini-cart drawer content — loaded on every page because the drawer is site-wide. */
/*
 * Drawer layout: header and footer fixed, the item list scrolls on its own, subtotal + buttons
 * stay pinned and reachable however many items there are. (The original .cart__body centred
 * its content with grid, so a long cart overflowed off both ends with no way to scroll.)
 */
.cart__top,
.cart__foot { flex: none; }
.cart .cart__body {
  display: flex;
  flex-direction: column;
  min-height: 0; /* lets the flex child shrink so the list can scroll */
  place-items: initial;
  text-align: left;
  gap: 0;
  padding: 16px 20px 0;
  overflow: hidden;
}
.cart .widget_shopping_cart_content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cart .woocommerce-mini-cart {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain; /* scrolling the list never drags the page behind */
  -webkit-overflow-scrolling: touch;
  align-content: start;
  padding: 4px 6px 14px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--pop) transparent;
}
.cart .woocommerce-mini-cart::-webkit-scrollbar { width: 6px; }
.cart .woocommerce-mini-cart::-webkit-scrollbar-thumb { background: var(--pop); border-radius: 999px; }
.cart .woocommerce-mini-cart::-webkit-scrollbar-track { background: transparent; }
.cart .woocommerce-mini-cart__total,
.cart .woocommerce-mini-cart__buttons { flex: none; }
.cart .woocommerce-mini-cart__buttons { padding-bottom: 18px; }
.cart .woocommerce-mini-cart__empty-message { margin: auto 0; padding: 24px 0; }

.cart .woocommerce-mini-cart{list-style:none;margin:0;display:grid;gap:12px;}
.cart .woocommerce-mini-cart-item{position:relative;display:block;border:2px solid var(--paper);padding:10px 46px 10px 10px;font-size:13px;}
.cart .woocommerce-mini-cart-item a:not(.remove){overflow-wrap:anywhere;}
.cart .woocommerce-mini-cart-item a:not(.remove){display:flex;align-items:center;gap:12px;font-family:var(--font-display);text-transform:uppercase;font-size:13px;line-height:1.2;}
.cart .woocommerce-mini-cart-item img{flex:none;width:56px;height:56px;object-fit:contain;margin:0;}
/* Flavour cans in the drawer: the whole can, upright (theme art via woocommerce_cart_item_thumbnail). */
.cart .woocommerce-mini-cart-item img.stacko-cart-can{width:32px;height:64px;margin-inline:12px;filter:drop-shadow(0 6px 8px rgba(0,0,0,.45));}
.cart .woocommerce-mini-cart-item .variation{margin:4px 0 0 68px;font-size:11px;opacity:.8;}
.cart .woocommerce-mini-cart-item .variation dt,.cart .woocommerce-mini-cart-item .variation dd,.cart .woocommerce-mini-cart-item .variation dd p{display:inline;margin:0;}
.cart .woocommerce-mini-cart-item .quantity{display:block;margin:2px 0 0 68px;font-size:12px;opacity:.85;}
.cart .woocommerce-mini-cart-item a.remove{position:absolute;top:6px;right:8px;color:var(--paper);font-size:20px;line-height:1;}
.cart .woocommerce-mini-cart-item a.remove:hover{color:var(--pop);background:none;}
.cart .woocommerce-mini-cart__total{display:flex;justify-content:space-between;margin:18px 0 12px;padding-top:14px;border-top:3px solid var(--paper);font-family:var(--font-display);text-transform:uppercase;}
.cart .woocommerce-mini-cart__total .amount{color:var(--pop);font-family:var(--heading);font-size:22px;}
.cart .woocommerce-mini-cart__buttons{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:0;}
.cart .woocommerce-mini-cart__buttons .button{display:block;text-align:center;margin:0;font-family:var(--font-display);text-transform:uppercase;font-size:13px;background:var(--pop);color:var(--ink);border:3px solid var(--ink);padding:12px 10px;box-shadow:var(--hard-sm);}
.cart .woocommerce-mini-cart__buttons .button:not(.checkout){background:var(--paper);}
.cart .woocommerce-mini-cart__empty-message{font-family:var(--font-display);text-transform:uppercase;font-size:18px;text-align:center;}

/* WooCommerce: generic wrapper used by archive, cart, checkout and account pages. */
.wc-main { padding-block: calc(var(--hdr-h) + 48px) var(--section-y); }
