/* Smoking Kills, v09: Drab Pack.
   A cuboid built to the 2015 and 2016 pack rules, holding no cigarettes. */

:root {
  --drab: #4a412a;          /* Pantone 448 C */
  --drab-hi: #574d33;
  --drab-lo: #3a3320;
  --room: #12100a;
  --grey: #d0d0ce;          /* Cool Gray 2 C, screen approximation */
  --grey-dim: #9d9c94;
  --white: #ffffff;
  --black: #000000;
  --gold: #dc9e5d;
  --sans: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Martian Mono", ui-monospace, Menlo, monospace;
  --W: 300px; --D: 120px; --Hb: 380px; --L: 100px; --bw: 18px; --m: 14px;
  --imgW: 284px; --imgH: 190px;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { background: var(--room); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--room);
  color: var(--grey);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a, button { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* Header */

.top {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.home {
  display: inline-block;
  padding: 10px 12px;
  border: 1px solid rgba(208, 208, 206, .38);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .01em;
  text-decoration: none;
  color: var(--grey);
  background: rgba(74, 65, 42, .35);
}
.home:hover { background: var(--grey); color: #1c1810; }

.chno {
  font: 400 11px/1 var(--mono);
  letter-spacing: .08em;
  color: var(--grey-dim);
}

.sound {
  padding: 10px 12px;
  border: 1px solid rgba(208, 208, 206, .38);
  background: transparent;
  color: var(--grey);
  font-weight: 500;
  font-size: 14px;
}
.sound[aria-pressed="true"] { background: var(--grey); color: #1c1810; }

/* Stage */

.work { position: relative; }

.stage {
  position: relative;
  height: var(--stageH, 640px);
  overflow: hidden;
  perspective: 1900px;
  perspective-origin: 50% 42%;
  touch-action: pan-y;
  cursor: grab;
  transition: height .9s cubic-bezier(.3, .1, .2, 1);
  user-select: none;
  -webkit-user-select: none;
}
.stage.dragging { cursor: grabbing; }
.stage.is-flat { cursor: default; perspective-origin: 50% 0; }

.spot {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(42% 52% at 50% 46%, rgba(120, 106, 70, .34), rgba(40, 35, 22, .12) 60%, transparent 78%);
  pointer-events: none;
  transition: opacity .8s;
}
.is-flat .spot { opacity: .35; }

.floor {
  position: absolute;
  left: 50%;
  top: 0;
  width: calc(var(--W) * 1.5);
  height: calc(var(--D) * .9);
  margin-left: calc(var(--W) * -.75);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .62), rgba(0, 0, 0, .25) 55%, transparent);
  filter: blur(6px);
  pointer-events: none;
  transition: opacity .6s, transform 1.2s;
}
.is-flat .floor { opacity: 0; }

.rig {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

/* Panels of the net. Each child sits on its parent's edge, hinged there. */

.pn {
  position: absolute;
  transform-style: preserve-3d;
  transition: transform .85s cubic-bezier(.35, .1, .2, 1);
}

.pn-front { left: 0; top: 0; width: var(--W); height: var(--Hb); transform-origin: 50% 0; transition: transform 1.3s cubic-bezier(.3, .1, .2, 1); }
.pn-left, .pn-lidleft { right: 100%; top: 0; width: var(--D); transform-origin: 100% 50%; }
.pn-right, .pn-lidright { left: 100%; top: 0; width: var(--D); transform-origin: 0 50%; }
.pn-left, .pn-right { height: var(--Hb); }
.pn-lidleft, .pn-lidright { height: var(--L); }
.pn-bottom { left: 0; top: 100%; width: var(--W); height: var(--D); transform-origin: 50% 0; }
.pn-back { left: 0; top: 100%; width: var(--W); height: var(--Hb); transform-origin: 50% 0; }
.pn-lidback { left: 0; top: 100%; width: var(--W); height: var(--L); transform-origin: 50% 0; }
.pn-lidtop { left: 0; top: 100%; width: var(--W); height: var(--D); transform-origin: 50% 0; }
.pn-lidfront { left: 0; top: 100%; width: var(--W); height: var(--L); transform-origin: 50% 0; }

/* Faces */

.f {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.f.out {
  background-color: var(--drab);
  background-image: var(--grain), linear-gradient(160deg, var(--drab-hi), var(--drab) 45%, var(--drab-lo));
  color: var(--grey);
}

.f.in {
  transform: rotateY(180deg);
  background: var(--white);
  color: var(--black);
}

/* Light falling on each outer face, set from the pack's angle */
.f.out::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #000;
  opacity: var(--shade, 0);
  pointer-events: none;
}

/* Cellophane: clear and unmarked, with a highlight that moves as the pack turns */
.f.out.gloss::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(104deg, transparent 34%, rgba(255, 255, 255, .13) 45%, rgba(255, 255, 255, .03) 52%, transparent 62%);
  background-size: 320% 100%;
  background-position: calc(var(--sheen, 50) * 1%) 0;
  transition: opacity .5s;
}
.torn .f.out.gloss::after { opacity: 0; }

/* Dieline: cut and fold lines, shown once the pack lies flat */
.f::after { pointer-events: none; }
.f .cut {
  position: absolute;
  inset: 0;
  z-index: 6;
  border: 1px solid transparent;
  pointer-events: none;
  transition: border-color .6s .9s;
}
.is-flat .f .cut { border-color: rgba(208, 208, 206, .5); }
.is-flat .f.in .cut { border-color: rgba(0, 0, 0, .35); }
.f .cut[data-hinge="top"] { border-top-style: dashed; }
.f .cut[data-hinge="left"] { border-left-style: dashed; }
.f .cut[data-hinge="right"] { border-right-style: dashed; }
.is-flat .f .cut[data-hinge="top"] { border-top-color: var(--gold); }
.is-flat .f .cut[data-hinge="left"] { border-left-color: var(--gold); }
.is-flat .f .cut[data-hinge="right"] { border-right-color: var(--gold); }

/* Turned content (the back and the lid back hang upside down in the net) */
.rot {
  position: absolute;
  inset: 0;
  transition: transform .7s cubic-bezier(.3, .1, .2, 1);
  transform: rotate(180deg);
}
.is-flat .rot { transform: rotate(0deg); transition-delay: .95s; }

/* The regulated warning box: black bold on white inside a black border */

.warn {
  position: absolute;
  left: var(--m);
  right: var(--m);
  top: var(--m);
  background: var(--white);
  color: var(--black);
  border: var(--bw) solid var(--black);
  padding: calc(var(--bw) * .55) calc(var(--bw) * .6);
}
.f.in .warn { box-shadow: none; }

.fit {
  height: 100%;
  overflow: hidden;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.12;
  letter-spacing: -.012em;
  hyphens: none;
  overflow-wrap: break-word;
}
.fit p { margin: 0; }
.fit .h {
  display: block;
  margin: 0 0 .3em;
  padding-bottom: .22em;
  border-bottom: 2px solid #000;
  font-weight: 800;
  font-size: 1em;
  letter-spacing: -.015em;
}
.fit .t { font-weight: 700; }

/* Name and variant, as the rules allow: Cool Gray 2 C, centred, 14 pt and 10 pt at most */

.plate {
  position: absolute;
  left: var(--m);
  right: var(--m);
  bottom: var(--m);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  color: var(--grey);
}
.plate h1 {
  margin: 0;
  font-weight: 500;
  font-size: 14pt;
  line-height: 1.1;
  letter-spacing: 0;
}
.plate .variant {
  margin: 0;
  max-width: 92%;
  font-weight: 400;
  font-size: 10pt;
  line-height: 1.3;
  color: var(--grey);
}

/* Small print on sides, lid and base */

.vert {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--Hb) - 2 * var(--m));
  transform: translate(-50%, -50%) rotate(-90deg);
  text-align: center;
  font-size: 10pt;
  line-height: 1.35;
  font-weight: 500;
  color: var(--grey);
}
.vert span { display: block; font-family: var(--mono); font-size: 7.5pt; letter-spacing: .06em; font-weight: 400; color: var(--grey-dim); margin-bottom: 4px; }
.pn-lidleft .vert, .pn-lidright .vert { width: calc(var(--L) - 8px); font-size: 7pt; }

.small {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  text-align: center;
  font-size: 10pt;
  line-height: 1.25;
  font-weight: 500;
}
.small .k { font-family: var(--mono); font-weight: 400; font-size: 7.5pt; letter-spacing: .06em; color: var(--grey-dim); }
.f.in .small { color: #555; }
.f.in .small .k { color: #888; }

/* Lid hit area and the tear strip */

.lidhit {
  position: absolute;
  inset: 0;
  z-index: 7;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.is-flat .lidhit { display: none; }

.strip {
  position: absolute;
  left: 0;
  right: 0;
  top: 7%;
  height: 5px;
  z-index: 6;
  background: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, .05) 40%, rgba(255, 255, 255, .22));
  transform-origin: 0 50%;
  transform: scaleX(calc(1 - var(--tear, 0)));
  pointer-events: none;
  transition: opacity .4s;
}
.torn .strip { opacity: 0; }

.tab {
  position: absolute;
  left: 100%;
  top: calc(7% - 9px);
  width: 30px;
  height: 22px;
  margin-left: -2px;
  padding: 0;
  border: 0;
  border-radius: 0 6px 6px 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, .18));
  box-shadow: 0 1px 0 rgba(0, 0, 0, .3);
  transform: translateZ(1px) translateX(calc(var(--tear, 0) * 40px));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  cursor: grab;
  touch-action: none;
}
.tab::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 6px;
  width: 6px;
  height: 10px;
  border-left: 1px solid rgba(0, 0, 0, .45);
  border-right: 1px solid rgba(0, 0, 0, .45);
}
.torn .tab { display: none; }

/* Contents and the inner frame */

.contents {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--imgW);
  transform-style: flat;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 1.1s cubic-bezier(.3, .1, .2, 1);
}
.contents img {
  display: block;
  width: 100%;
  height: var(--imgH);
  object-fit: cover;
  background: #0d0b07;
}
.contents figcaption {
  position: absolute;
  left: 0;
  bottom: 100%;
  padding-bottom: 6px;
  font: 400 10px/1.4 var(--mono);
  letter-spacing: .06em;
  color: var(--grey-dim);
  opacity: 0;
  transition: opacity .5s;
}
.is-flat .contents figcaption { opacity: 1; transition-delay: 1.2s; }

.frame {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--W) - 16px);
  background: var(--white);
  color: var(--black);
  border: calc(var(--bw) * .55) solid var(--black);
  padding: 14px 16px 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 1.2s cubic-bezier(.3, .1, .2, 1);
  clip-path: polygon(0 0, 30% 0, 36% 14px, 64% 14px, 70% 0, 100% 0, 100% 100%, 0 100%);
}
.frame-k {
  margin: 10px 0 10px;
  font: 400 10px/1.4 var(--mono);
  letter-spacing: .06em;
  color: #6b6b66;
}
.frame ul {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.25;
}
.frame li { padding: 5px 0; border-bottom: 1px solid #000; }
.frame li:first-child { border-top: 1px solid #000; }
.price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
}
.price b { font-weight: 800; font-size: 28px; letter-spacing: -.02em; }
.price span { font-weight: 500; font-size: 15px; }
.buy {
  display: block;
  width: 100%;
  padding: 13px 10px;
  border: 0;
  background: var(--black);
  color: var(--white);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .01em;
}
.buy:hover { background: #2a2a2a; }
.status {
  min-height: 1.3em;
  margin: 8px 0 0;
  font-weight: 700;
  font-size: 16px;
}

/* Controls */

.controls {
  position: relative;
  bottom: 0;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
}
.stage.is-flat ~ .controls { position: sticky; bottom: 10px; }
.boot .pn, .boot .pn-front, .boot .contents, .boot .frame, .boot .rot { transition: none !important; }
.ctl {
  min-width: 92px;
  padding: 12px 16px;
  border: 1px solid rgba(208, 208, 206, .5);
  background: rgba(30, 26, 16, .88);
  color: var(--grey);
  font-weight: 600;
  font-size: 15px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.ctl:hover { border-color: var(--grey); }
.ctl-main {
  background: var(--white);
  color: var(--black);
  border: 4px solid var(--black);
  outline: 1px solid rgba(208, 208, 206, .5);
  font-weight: 800;
}
.ctl-main:hover { background: #ececea; }
.ctl[aria-pressed="true"] { background: var(--grey); color: #17140c; }
.ctl-main[aria-pressed="true"] { background: var(--white); color: var(--black); }
.hint {
  flex-basis: 100%;
  margin: 2px 0 0;
  text-align: center;
  font: 300 11px/1.5 var(--mono);
  letter-spacing: .04em;
  color: var(--grey-dim);
}

/* Specification */

.spec {
  margin: 0;
  padding: 18px 16px 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  font-size: 16px;
}
.spec div {
  display: grid;
  grid-template-columns: 7.2em 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(208, 208, 206, .2);
}
.spec dt {
  font: 400 10.5px/1.6 var(--mono);
  letter-spacing: .06em;
  color: var(--grey-dim);
  padding-top: 2px;
}
.spec dd { margin: 0; line-height: 1.4; color: var(--grey); }

/* Next chapter */

.next {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  margin: 28px 16px 40px;
  padding: 22px 0 0;
  border-top: 1px solid rgba(208, 208, 206, .25);
}
.next-k { font: 400 11px/1 var(--mono); letter-spacing: .08em; color: var(--grey-dim); }
.next-a {
  font-weight: 700;
  font-size: 22px;
  color: var(--white);
  text-decoration: none;
  border-bottom: 3px solid var(--white);
  padding-bottom: 2px;
}
.next-a:hover { color: var(--gold); border-color: var(--gold); }
.next-home { margin-left: auto; font-size: 15px; color: var(--grey); }

/* Desktop: the specification sits beside the pack */
@media (min-width: 1180px) {
  .top { padding: 16px 32px; }
  .spec {
    position: absolute;
    left: 32px;
    top: 18px;
    width: 268px;
    padding: 0;
    z-index: 4;
    font-size: 14.5px;
  }
  .spec div { grid-template-columns: 1fr; gap: 3px; padding: 9px 0; }
  .next { margin: 28px 32px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage, .pn, .pn-front, .rot, .contents, .frame, .floor, .spot, .f .cut { transition-duration: .01s !important; transition-delay: 0s !important; }
}
