/* Pricetrail: shelf-tag & receipt design language.
   Ink-navy lines, warm paper, signal amber. Hard edges, no blur. */

:root {
  --ink: #0d1829;
  --ink-2: #16243b;
  --ink-3: #24344f;
  --ink-soft: #4a5872;
  --ink-mute: #7d889c;
  --ink-line: rgba(13, 24, 41, 0.14);

  --paper: #f3efe6;
  --paper-hi: #fbf9f4;
  --paper-lo: #e9e3d6;

  --amber: #f4a51c;
  --amber-hi: #ffb938;
  --amber-ink: #8a5a00;

  --display: 'Archivo', 'Arial Narrow', sans-serif;
  --sans: 'Archivo', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --edge: 2px solid var(--ink);
  --drop: 6px 6px 0 var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-color: var(--paper);
  /* faint graph paper */
  background-image:
    linear-gradient(var(--ink-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ink-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  background-attachment: fixed;
}

body::before {
  /* fade the grid so it never competes with content */
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 80% at 50% 0%, rgba(243, 239, 230, 0.55), var(--paper) 70%);
  pointer-events: none;
}

main { flex: 1; overflow-x: clip; }
button { font: inherit; color: inherit; cursor: pointer; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Nav ---------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 32px;
  border-bottom: var(--edge);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.brand-mark { width: 36px; height: 28px; overflow: visible; }

.nav-badge {
  position: relative;
  padding: 5px 12px 5px 22px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--amber);
  border: var(--edge);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%);
}

.nav-badge::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 1.5px var(--ink);
}

/* ---------- Hero ---------- */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 72px 32px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'copy tag'
    'search search';
  gap: 40px 48px;
  align-items: end;
}

.hero-copy { grid-area: copy; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.kicker::before {
  content: '';
  width: 28px;
  height: 2px;
  background: var(--ink);
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-stretch: 66%;
  font-weight: 850;
  font-size: clamp(60px, 10.5vw, 148px);
  line-height: 0.86;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.h1-line { display: block; white-space: nowrap; }

h1 mark {
  position: relative;
  color: var(--ink);
  background: none;
  padding: 0 0.04em;
  z-index: 0;
}

h1 mark::before {
  content: '';
  position: absolute;
  inset: 0.16em -0.04em 0.06em;
  z-index: -1;
  background: var(--amber);
  transform: skewX(-8deg);
  box-shadow: 0.06em 0.06em 0 var(--ink);
}

.subtitle {
  max-width: 40ch;
  margin: 28px 0 0;
  font-size: clamp(17px, 1.6vw, 20px);
  line-height: 1.45;
  color: var(--ink-soft);
}

/* Decorative price tag */
.hero-tag {
  grid-area: tag;
  padding: 0 12px 24px 0;
}

.tag {
  position: relative;
  display: grid;
  gap: 2px;
  width: 230px;
  padding: 22px 26px 22px 56px;
  background: var(--paper-hi);
  border: var(--edge);
  box-shadow: var(--drop);
  clip-path: polygon(30px 0, 100% 0, 100% 100%, 30px 100%, 0 50%);
  transform: rotate(-5deg);
  font-family: var(--mono);
  animation: swing 5s ease-in-out infinite;
  transform-origin: 20px 50%;
}

/* the clip-path eats the left border; redraw it */
.tag::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 31px;
  height: 100%;
  background:
    linear-gradient(to top right, transparent calc(50% - 1.5px), var(--ink) calc(50% - 1.5px), var(--ink) calc(50% + 1px), transparent calc(50% + 1px)) top / 100% 50% no-repeat,
    linear-gradient(to bottom right, transparent calc(50% - 1.5px), var(--ink) calc(50% - 1.5px), var(--ink) calc(50% + 1px), transparent calc(50% + 1px)) bottom / 100% 50% no-repeat;
}

.tag-hole {
  position: absolute;
  left: 22px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.tag-was {
  font-size: 15px;
  color: var(--ink-mute);
  text-decoration: line-through;
  text-decoration-color: #c2410c;
  text-decoration-thickness: 2px;
}

.tag-now {
  font-family: var(--display);
  font-stretch: 70%;
  font-weight: 850;
  font-size: 54px;
  line-height: 0.95;
}

.tag-label {
  justify-self: start;
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--amber);
}

@keyframes swing {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(-2deg); }
}

/* ---------- Search ---------- */
.search-wrap { grid-area: search; }

.search {
  display: flex;
  background: var(--paper-hi);
  border: var(--edge);
  box-shadow: var(--drop);
  transition: box-shadow 0.15s, transform 0.15s;
}

.search:focus-within {
  box-shadow: 8px 8px 0 var(--ink);
  transform: translate(-2px, -2px);
}

.search.has-error { box-shadow: 6px 6px 0 #c2410c; }

.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search-field input {
  width: 100%;
  height: 68px;
  padding: 0 22px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
}

.search-field input::placeholder { color: var(--ink-mute); }

.btn-primary {
  position: relative;
  flex: none;
  padding: 0 30px;
  border: 0;
  border-left: var(--edge);
  background: var(--amber);
  color: var(--ink);
  font-family: var(--display);
  font-stretch: 85%;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: background 0.12s;
}

.btn-primary:hover { background: var(--amber-hi); }
.btn-primary:active { background: #e39612; }
.btn-primary:focus-visible { outline: 3px solid var(--ink); outline-offset: -6px; }

.spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(13, 24, 41, 0.25);
  border-top-color: var(--ink);
  border-radius: 50%;
  opacity: 0;
}

.is-loading .btn-label { opacity: 0; }
.is-loading .spinner { opacity: 1; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-error {
  min-height: 24px;
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 14px;
  color: #b2360b;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-soft);
}

.samples > span {
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.samples button {
  padding: 6px 12px;
  background: var(--paper-hi);
  border: 1.5px solid var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
}

.samples button:hover { background: var(--amber); }
.samples button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* ---------- Result ---------- */
.result {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 32px 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  scroll-margin-top: 16px;
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.demo-banner {
  border: var(--edge);
  background:
    repeating-linear-gradient(-45deg, var(--amber) 0 14px, var(--ink) 14px 28px) top / 100% 8px no-repeat,
    var(--paper-hi);
  padding: 20px 20px 14px;
}

.demo-banner p {
  margin: 0;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.demo-banner strong {
  margin-right: 8px;
  padding: 1px 7px;
  background: var(--ink);
  color: var(--amber);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 28px;
  align-items: stretch;
}

/* Ticket */
.ticket {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper-hi);
  border: var(--edge);
  box-shadow: var(--drop);
}

.ticket-top {
  display: flex;
  gap: 16px;
  padding: 20px;
}

.product-image {
  flex: none;
  width: 92px;
  height: 92px;
  border: 1.5px solid var(--ink);
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.product-image img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }

.product-image.placeholder {
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(13, 24, 41, 0.05) 6px 7px),
    var(--paper);
}

.product-image.placeholder svg { width: 44px; height: 44px; margin-bottom: 10px; }

.product-image.placeholder::after {
  content: 'Demo';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1px 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
}

.product-info { min-width: 0; }

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  overflow-wrap: anywhere;
}

.ticket h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* perforated cut with side notches */
.ticket-cut {
  position: relative;
  height: 0;
  margin: 0 20px;
  border-top: 2px dashed var(--ink-line);
  border-top-color: rgba(13, 24, 41, 0.35);
}

.ticket-cut::before,
.ticket-cut::after {
  content: '';
  position: absolute;
  top: -12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
  border: var(--edge);
}

.ticket-cut::before { left: -33px; clip-path: inset(0 0 0 50%); }
.ticket-cut::after { right: -33px; clip-path: inset(0 50% 0 0); }

.now { padding: 18px 20px 20px; }

.row-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.now-value {
  margin: 4px 0 8px;
  font-family: var(--display);
  font-stretch: 68%;
  font-weight: 850;
  font-size: 76px;
  line-height: 0.9;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.now-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-soft);
}

.now-note strong {
  padding: 1px 6px;
  background: var(--amber);
  color: var(--ink);
  font-weight: 600;
}

.rows { margin: 0; padding: 14px 20px 4px; }

.row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  font-family: var(--mono);
}

.row dt {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* dotted leader like a receipt */
.row dt::after {
  content: '';
  display: inline-block;
}

.row dd {
  flex: 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: radial-gradient(circle, rgba(13, 24, 41, 0.4) 1px, transparent 1.5px) left 0.72em / 7px 4px repeat-x;
}

.row-value {
  padding-left: 8px;
  background: var(--paper-hi);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.row-date {
  font-size: 11.5px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--paper-hi);
  padding-left: 8px;
}

.ticket-foot {
  margin-top: auto;
  padding: 16px 20px 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.barcode {
  display: flex;
  align-items: stretch;
  min-width: 0;
  height: 34px;
  gap: 2px;
  overflow: hidden;
}

.barcode span { flex: none; background: var(--ink); }

.product-link {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--amber);
  white-space: nowrap;
}

.product-link:hover { background: var(--amber); }

/* Chart panel */
.chart-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px 24px 16px;
  background: var(--ink);
  color: var(--paper);
  border: var(--edge);
  box-shadow: 6px 6px 0 var(--amber);
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

.chart-head h3 {
  margin: 0;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 26px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.chart-summary {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #a7b1c4;
  font-variant-numeric: tabular-nums;
}

.chart-summary .up { color: #ff9b7a; }
.chart-summary .down { color: var(--amber); }

.ranges {
  display: inline-flex;
  border: 1.5px solid #3a4a66;
}

.ranges button {
  min-width: 52px;
  padding: 8px 10px;
  border: 0;
  border-left: 1.5px solid #3a4a66;
  background: transparent;
  color: #a7b1c4;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
}

.ranges button:first-child { border-left: 0; }
.ranges button:hover { color: var(--paper); background: var(--ink-2); }

.ranges button[aria-selected='true'] {
  background: var(--amber);
  color: var(--ink);
}

.chart {
  position: relative;
  flex: 1;
  min-height: 340px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.chart svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }

.chart .grid line { stroke: rgba(243, 239, 230, 0.08); stroke-width: 1; }
.chart .axis text { fill: #7f8ba2; font-size: 11px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chart .price-line { fill: none; stroke: var(--amber); stroke-width: 2.25; stroke-linejoin: miter; stroke-linecap: square; }
.chart .gap-line { stroke: #7f8ba2; stroke-width: 2; stroke-dasharray: 2 4; }
.chart .low-dot { fill: var(--ink); stroke: var(--paper); stroke-width: 2; }
.chart .low-label { fill: var(--paper); font-size: 10.5px; font-weight: 600; font-family: var(--mono); letter-spacing: 0.1em; }
.chart .end-dot { fill: var(--amber); stroke: var(--ink); stroke-width: 2.5; }
.chart .end-halo { fill: var(--amber); opacity: 0.3; transform-box: fill-box; transform-origin: center; animation: halo 2.4s ease-out infinite; }
.chart .crosshair { stroke: var(--paper); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.chart .hover-dot { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.chart .draw { animation: fade 0.4s ease-out both; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes halo {
  0% { transform: scale(0.6); opacity: 0.5; }
  100% { transform: scale(2.4); opacity: 0; }
}

.tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
  padding: 8px 12px;
  background: var(--paper-hi);
  color: var(--ink);
  border: var(--edge);
  box-shadow: 4px 4px 0 var(--amber);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
}

.tooltip.visible { opacity: 1; }
.tooltip .tt-price { font-family: var(--display); font-stretch: 75%; font-size: 24px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tooltip .tt-date { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.tooltip .tt-oos { font-family: var(--mono); font-size: 14px; font-weight: 600; color: #b2360b; }

.chart-hint {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #6c7891;
}

/* Loading skeleton */
.is-skeleton .now-value,
.is-skeleton .row-value,
.is-skeleton .ticket h2,
.is-skeleton .eyebrow,
.is-skeleton .now-note {
  color: transparent !important;
  background: repeating-linear-gradient(-45deg, var(--paper-lo) 0 6px, var(--paper) 6px 12px) !important;
  animation: stripe 0.8s linear infinite;
}

@keyframes stripe { to { background-position: 17px 0; } }

/* ---------- Footer ---------- */
.footer {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 32px 30px;
  border-top: var(--edge);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.footer p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .result-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; grid-template-areas: 'copy' 'search'; }
  .hero-tag { display: none; }
}

@media (max-width: 760px) {
  .hero { padding-top: 48px; }
}

@media (max-width: 600px) {
  .nav { padding: 14px 16px; }
  .brand { font-size: 21px; }
  .hero { padding: 36px 16px 36px; gap: 28px; }
  h1 { font-size: clamp(40px, 13vw, 80px); }
  .h1-line { display: inline; white-space: normal; }
  .subtitle { margin-top: 20px; }
  .search { flex-direction: column; box-shadow: 4px 4px 0 var(--ink); }
  .search:focus-within { box-shadow: 5px 5px 0 var(--ink); transform: none; }
  .search-field input { height: 58px; padding: 0 16px; }
  .btn-primary { height: 54px; border-left: 0; border-top: var(--edge); }
  .result { padding: 0 16px 64px; gap: 16px; }
  .result-grid { gap: 20px; }
  .ticket { box-shadow: 4px 4px 0 var(--ink); }
  .rows { padding-top: 12px; }
  .ticket-top { padding: 16px; gap: 14px; }
  .product-image { width: 76px; height: 76px; }
  .product-image.placeholder svg { width: 36px; height: 36px; }
  .ticket-cut { margin: 0 16px; }
  .ticket-cut::before { left: -29px; }
  .ticket-cut::after { right: -29px; }
  .now, .rows, .ticket-foot { padding-left: 16px; padding-right: 16px; }
  .now-value { font-size: 64px; }
  .chart-panel { padding: 18px 12px 12px; box-shadow: 4px 4px 0 var(--amber); }
  .chart-head { padding: 0 4px; }
  .chart { min-height: 260px; }
  .ranges { width: 100%; }
  .ranges button { flex: 1; min-width: 0; }
  .chart-hint { padding: 0 4px; }
  .footer { padding: 20px 16px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
