/* ============================================================
   PEGASUS — shared tokens, 3D pack, cigarette, controls
   ============================================================ */
:root {
  --bg: #0d0a08; --bg-2: #130e0b;
  --surface: #19130f; --surface-2: #211913; --surface-3: #2b2119;
  --line: rgba(255, 224, 186, .08); --line-2: rgba(255, 224, 186, .15);
  --fg: #f4ebde; --fg-2: #bfac97; --fg-3: #877561;
  --gold: #d9a441; --gold-2: #f3cf7a; --gold-ink: #1b1206; --gold-soft: rgba(217, 164, 65, .13);
  --ember: #ff6a2b; --ember-2: #ffb347;
  --ok: #6cc58a; --ok-bg: rgba(108, 197, 138, .13);
  --bad: #f0604f; --bad-bg: rgba(240, 96, 79, .13);
  --warn: #f2a53b; --warn-bg: rgba(242, 165, 59, .14);
  --info: #86b6e6; --info-bg: rgba(134, 182, 230, .13);
  --shadow-1: inset 0 1px 0 rgba(255, 255, 255, .03), 0 10px 30px -16px rgba(0, 0, 0, .75);
  --shadow-2: inset 0 1px 0 rgba(255, 255, 255, .05), 0 30px 60px -24px rgba(0, 0, 0, .85);
  --hero-a: #2a140d; --hero-b: #0c0807;
  --smoke: 228, 218, 206;
  --r: 18px; --r-sm: 12px; --r-xs: 9px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f3ebdf; --bg-2: #ede2d3;
  --surface: #fffaf2; --surface-2: #f9f1e6; --surface-3: #f1e6d6;
  --line: rgba(70, 40, 15, .1); --line-2: rgba(70, 40, 15, .18);
  --fg: #2a1c12; --fg-2: #6c5744; --fg-3: #9a8571;
  --gold: #a26c14; --gold-2: #c38a28; --gold-ink: #fff8ea; --gold-soft: rgba(162, 108, 20, .1);
  --ember: #d6521b; --ember-2: #ef8a39;
  --ok: #2c8a4e; --ok-bg: rgba(44, 138, 78, .11);
  --bad: #c2372a; --bad-bg: rgba(194, 55, 42, .1);
  --warn: #b26a08; --warn-bg: rgba(178, 106, 8, .11);
  --info: #2c6aa8; --info-bg: rgba(44, 106, 168, .1);
  --shadow-1: 0 1px 2px rgba(70, 40, 15, .06), 0 10px 26px -16px rgba(70, 40, 15, .3);
  --shadow-2: 0 2px 4px rgba(70, 40, 15, .06), 0 30px 60px -28px rgba(70, 40, 15, .45);
  --hero-a: #3b1d12; --hero-b: #160d09;
  --smoke: 236, 226, 214;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 106, 43, .10), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(217, 164, 65, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--fg); font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
html[data-theme="light"] body {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(214, 82, 27, .08), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(162, 108, 20, .08), transparent 60%),
    var(--bg);
}
/* film-grain / tobacco-paper texture */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html[data-theme="light"] .grain { opacity: .12; mix-blend-mode: multiply; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ic { width: 18px; height: 18px; flex-shrink: 0; }
.serif { font-family: var(--serif); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--fg-2); }
.t-ok { color: var(--ok) !important; } .t-bad { color: var(--bad) !important; }
.t-warn { color: var(--warn) !important; } .t-gold { color: var(--gold) !important; }
.gold-text {
  background: linear-gradient(180deg, #fbe3a4 0%, #e0aa48 45%, #a8711d 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- BUTTONS ---------- */
.btn {
  --b: var(--surface-3); --c: var(--fg);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--b); color: var(--c); font-weight: 650; font-size: 14px; letter-spacing: .01em;
  transition: transform .18s var(--ease), box-shadow .25s var(--ease), background .2s, filter .2s;
  user-select: none; white-space: nowrap; position: relative;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-xs); }
.btn.xs { min-height: 28px; padding: 0 9px; font-size: 12px; border-radius: 8px; gap: 5px; }
.btn.xs .ic { width: 14px; height: 14px; }
.btn.gold {
  --c: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 22px -10px rgba(217, 164, 65, .7);
}
.btn.gold:hover { filter: brightness(1.06); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 12px 28px -10px rgba(217, 164, 65, .85); }
.btn.ember { --c: #fff; background: linear-gradient(180deg, var(--ember-2), var(--ember)); box-shadow: 0 8px 22px -10px rgba(255, 106, 43, .75); }
.btn.ok { --c: #fff; background: linear-gradient(180deg, #7fd39b, #3f9e60); }
html[data-theme="light"] .btn.ok { background: linear-gradient(180deg, #3aa463, #26804a); }
.btn.danger { --b: var(--bad-bg); --c: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn.ghost { --b: transparent; border-color: var(--line-2); }
.btn.ghost:hover { --b: var(--surface-2); }
.btn .spin { width: 16px; height: 16px; border-width: 2px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--fg-2);
  transition: color .2s, background .2s, transform .15s var(--ease);
}
.icon-btn:hover { color: var(--fg); background: var(--surface-3); }
.icon-btn:active { transform: scale(.94); }

/* ---------- FORM ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .lbl { font-size: 12px; font-weight: 600; color: var(--fg-2); letter-spacing: .02em; }
.input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--fg); font-size: 14.5px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
html[data-theme="light"] .input { background: #fffdf9; }
.input::placeholder { color: var(--fg-3); }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
select.input {
  appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b08a52' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
input[type="date"].input { min-width: 0; }
.input.sm { min-height: 36px; padding: 6px 10px; font-size: 13.5px; border-radius: 9px; }
.input.qty { width: 74px; text-align: center; }
.input.money { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- SPINNER ---------- */
.spin {
  display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line-2); border-top-color: var(--gold);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   3D CIGARETTE PACK  (.pack > .pk > .spin3d > .pf*)
   ============================================================ */
.pack {
  --w: 120px; --h: 170px; --d: 46px;
  --lid: #7d151a; --lid-2: #3e0a0d;
  width: var(--w); height: var(--h); position: relative; perspective: 1000px; flex-shrink: 0;
}
.pack .pk {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform: rotateX(var(--prx, -14deg)) rotateY(var(--pry, 0deg));
  transition: transform .6s var(--ease-out);
}
.pack .spin3d { position: absolute; inset: 0; transform-style: preserve-3d; animation: pkSpin 18s linear infinite; }
.pack.still .spin3d { animation: none; transform: rotateY(-28deg); }
.pack.float { animation: pkFloat 6s ease-in-out infinite; }
@keyframes pkSpin { from { transform: rotateY(0deg); } to { transform: rotateY(360deg); } }
@keyframes pkFloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }

.pf { position: absolute; left: 0; top: 0; overflow: hidden; backface-visibility: hidden; }
.pf-front, .pf-back { width: var(--w); height: var(--h); }
.pf-front { transform: translateZ(calc(var(--d) / 2)); }
.pf-back { transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); }
.pf-right, .pf-left { width: var(--d); height: var(--h); left: calc((var(--w) - var(--d)) / 2); }
.pf-right { transform: rotateY(90deg) translateZ(calc(var(--w) / 2)); }
.pf-left { transform: rotateY(-90deg) translateZ(calc(var(--w) / 2)); }
.pf-top, .pf-bottom { width: var(--w); height: var(--d); top: calc((var(--h) - var(--d)) / 2); }
.pf-top { transform: rotateX(90deg) translateZ(calc(var(--h) / 2)); }
.pf-bottom { transform: rotateX(-90deg) translateZ(calc(var(--h) / 2)); }

.pf-front, .pf-back {
  background:
    linear-gradient(180deg, var(--lid) 0, var(--lid-2) 27%, transparent 27.2%),
    radial-gradient(130% 90% at 30% 10%, #2b1310 0%, #130807 55%, #0a0505 100%);
  border-radius: calc(var(--w) * .025);
}
/* flip-top seam + gold foil frame */
.pf-front::before, .pf-back::before {
  content: ''; position: absolute; left: 0; right: 0; top: 27%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(243, 207, 122, .9), transparent);
}
.pf-front .frame, .pf-back .frame {
  position: absolute; inset: calc(var(--w) * .06); top: calc(var(--h) * .33);
  border: 1px solid rgba(217, 164, 65, .55); border-radius: calc(var(--w) * .03);
}
.pf-front .crest {
  position: absolute; left: 50%; top: calc(var(--h) * .36); translate: -50% 0;
  width: calc(var(--w) * .42); height: calc(var(--w) * .42); color: #e7b65a;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6));
}
.pf-front .crest svg { width: 100%; height: 100%; }
.pf-front .name, .pf-back .name {
  position: absolute; left: 0; right: 0; text-align: center;
  font-family: var(--serif); font-weight: 700; letter-spacing: .12em;
}
.pf-front .name { top: calc(var(--h) * .63); font-size: calc(var(--w) * .135); }
.pf-front .sub, .pf-back .sub {
  position: absolute; left: 0; right: 0; text-align: center; color: #c99a4c;
  font-size: calc(var(--w) * .055); letter-spacing: .32em; font-weight: 600;
}
.pf-front .sub { top: calc(var(--h) * .74); }
.pf-front .grade {
  position: absolute; left: 0; right: 0; bottom: calc(var(--h) * .075); text-align: center;
  font-size: calc(var(--w) * .048); letter-spacing: .3em; color: rgba(243, 207, 122, .65);
}
.pf-front .lidmark, .pf-back .lidmark {
  position: absolute; left: 0; right: 0; top: calc(var(--h) * .1); text-align: center;
  font-family: var(--serif); font-style: italic; color: rgba(255, 220, 170, .8);
  font-size: calc(var(--w) * .075); letter-spacing: .08em;
}
/* moving foil shine */
.pf-front::after {
  content: ''; position: absolute; inset: -40%;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 235, 190, .16) 50%, transparent 58%);
  animation: shine 5.5s ease-in-out infinite;
}
@keyframes shine { 0%, 55% { translate: -60% 0; } 100% { translate: 60% 0; } }
.pf-back .name { top: calc(var(--h) * .42); font-size: calc(var(--w) * .1); color: #e2b35a; }
.pf-back .sub { top: calc(var(--h) * .52); }
.pf-back .barcode {
  position: absolute; left: 50%; bottom: calc(var(--h) * .09); translate: -50% 0;
  width: calc(var(--w) * .46); height: calc(var(--h) * .11); border-radius: 2px;
  background: repeating-linear-gradient(90deg, #f4ead8 0 2px, #f4ead8 2px 3px, transparent 3px 4px, #f4ead8 4px 5px, transparent 5px 7px), #1a0d0b;
  box-shadow: 0 0 0 3px #f4ead8;
  opacity: .9;
}
.pf-left, .pf-right {
  background:
    linear-gradient(180deg, var(--lid) 0, var(--lid-2) 27%, transparent 27.2%),
    linear-gradient(90deg, #0b0505, #1c0d0b 50%, #0b0505);
}
.pf-right { filter: brightness(.82); }
.pf-left { filter: brightness(.6); }
.pf-left span, .pf-right span {
  position: absolute; left: 50%; top: 64%; translate: -50% -50%; rotate: -90deg; white-space: nowrap;
  font-size: calc(var(--d) * .2); letter-spacing: .35em; color: rgba(217, 164, 65, .75); font-weight: 700;
}
.pf-top { background: linear-gradient(90deg, #5d1014, #8a1b20 50%, #5d1014); filter: brightness(1.15); }
.pf-bottom { background: #080404; }
.pack-shadow {
  position: absolute; left: 50%; bottom: calc(var(--h) * -.2); width: calc(var(--w) * 1.25); height: calc(var(--h) * .12);
  translate: -50% 0; border-radius: 50%; filter: blur(10px);
  background: radial-gradient(closest-side, rgba(0, 0, 0, .55), transparent);
  animation: pkShadow 6s ease-in-out infinite;
}
@keyframes pkShadow { 0%, 100% { scale: 1; opacity: .9; } 50% { scale: .85; opacity: .6; } }
.pack.mini .crest, .pack.mini .sub, .pack.mini .grade, .pack.mini .lidmark, .pack.mini .name,
.pack.mini .pf-left span, .pack.mini .pf-right span, .pack.mini .barcode, .pack.mini .pf-back .name { display: none; }
.pack.mini .frame { inset: 3px; top: 34%; }
.pack.mini .pf-front .mono {
  position: absolute; left: 0; right: 0; top: 40%; text-align: center;
  font-family: var(--serif); font-weight: 700; font-size: calc(var(--w) * .5); line-height: 1;
}

/* ============================================================
   LIT CIGARETTE
   ============================================================ */
.cig {
  --len: 260px; --th: 18px;
  position: relative; width: var(--len); height: var(--th); display: flex; border-radius: 3px;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .45));
}
.cig .filter {
  width: 30%; border-radius: 4px 0 0 4px;
  background:
    radial-gradient(circle at 20% 30%, rgba(120, 60, 10, .35) 0 1px, transparent 1.5px) 0 0 / 7px 6px,
    radial-gradient(circle at 70% 70%, rgba(120, 60, 10, .3) 0 1px, transparent 1.5px) 0 0 / 9px 7px,
    linear-gradient(180deg, #f6c37c, #d98d38 55%, #a8601f);
}
.cig .band { width: 2.2%; background: linear-gradient(180deg, #f6dc9a, #c9973e 60%, #8a611d); }
.cig .paper { flex: 1; background: linear-gradient(180deg, #ffffff, #efe9df 55%, #c9c0b2); }
.cig .ash {
  width: 7%;
  background:
    radial-gradient(circle at 30% 40%, rgba(0, 0, 0, .25) 0 1px, transparent 1.5px) 0 0 / 5px 4px,
    linear-gradient(180deg, #b9b2aa, #8c857d 60%, #5b5550);
}
.cig .ember {
  width: 3.4%; border-radius: 0 50% 50% 0;
  background: radial-gradient(circle at 30% 50%, #fff3b0, #ffb347 30%, #ff5a1f 60%, #7a1d08);
  box-shadow: 0 0 14px 4px rgba(255, 106, 43, .7), 0 0 40px 10px rgba(255, 106, 43, .25);
  animation: ember 2.4s ease-in-out infinite;
}
@keyframes ember {
  0%, 100% { filter: brightness(1); box-shadow: 0 0 14px 4px rgba(255, 106, 43, .65), 0 0 40px 10px rgba(255, 106, 43, .22); }
  45% { filter: brightness(1.35); box-shadow: 0 0 20px 7px rgba(255, 140, 60, .9), 0 0 60px 18px rgba(255, 106, 43, .35); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .pack .spin3d { transform: rotateY(-28deg); }
}
