@import url('https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,400;0,500;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* base */
  --ink: oklch(20% 0.012 250);
  --ink-soft: oklch(35% 0.012 250);
  --muted: oklch(45% 0.02 250);
  --stone: #C8CFD4; /* borders */
  --stone-light: oklch(85% 0.01 245);
  --paper: #E9E7E0; /* page background */
  --paper-alt: #E1DED6;
  --img-bg: #DDDBD3;

  /* line accents */
  --lienzo: oklch(58% 0.1 75);
  --estampa: oklch(55% 0.05 240);

  --surface: var(--paper);
  --surface-card: var(--paper-alt);

  --font-display: 'Archivo', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); text-decoration: underline; }
a:hover { color: var(--lienzo); }

button { font-family: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--stone); }

img { display: block; }

#app-shell {
  font-family: var(--font-display);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  position: relative;
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--stone);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 8px;
}
.brand { display: block; min-width: 0; flex-shrink: 1; }
.logo-mark { display: block; width: 163px; max-width: 50vw; height: auto; }

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
}
.cart-icon { width: 15px; height: 15px; flex-shrink: 0; color: var(--paper); }
.cart-badge { background: var(--paper); color: var(--ink); padding: 2px 6px; font-family: var(--font-mono); font-size: 11px; }
.cart-badge.bump { animation: badge-bump 0.6s ease; }
@keyframes badge-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.5); background: var(--lienzo); color: var(--paper); }
  100% { transform: scale(1); }
}

.back-btn {
  border: 1px solid var(--stone);
  background: transparent;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  color: var(--ink);
  flex-shrink: 0;
}

/* ---------- Catalog ---------- */
.catalog-intro { padding: 24px 16px 8px; }
.catalog-kicker { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; color: var(--estampa); margin-bottom: 10px; }
.catalog-intro h1 { font: 700 28px/1.2 var(--font-display); margin: 0 0 10px; }
.catalog-intro p { font: 400 14px/1.5 var(--font-display); color: var(--ink-soft); margin: 0; }

.section-head { padding: 20px 16px 4px; display: flex; align-items: baseline; gap: 10px; }
.section-head.with-rule { padding-top: 12px; border-top: 1px solid var(--stone); }
.section-dot { width: 8px; height: 8px; flex-shrink: 0; }
.section-dot.lienzo { background: var(--lienzo); }
.section-dot.estampa { background: var(--estampa); margin-top: 12px; }
.section-head h2 { font: 700 20px var(--font-display); margin: 0; }
.section-head.with-rule h2 { margin: 12px 0 0; }
.section-sub { padding: 0 16px 4px; }
.section-sub p { font: 400 13px/1.5 var(--font-display); color: var(--ink-soft); margin: 0; }

.product-grid { padding: 8px 16px 32px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.product-grid.estampa-grid { padding-bottom: 40px; }

.product-card {
  border: 1px solid var(--stone);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
  padding: 0;
  text-align: left;
}
.product-card:hover { border-color: var(--ink); }
.product-card-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--img-bg); }
.product-card-body { padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.product-card-tag { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; }
.product-card-tag.lienzo { color: var(--lienzo); }
.product-card-tag.estampa { color: var(--estampa); }
.product-card-title { font: 700 14px/1.25 var(--font-display); }
.product-card-price { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }

.catalog-footer { border-top: 1px solid var(--stone); padding: 20px 16px; display: flex; flex-direction: column; gap: 10px; }
.catalog-footer a { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--ink); background: none; border: none; padding: 0; cursor: pointer; text-align: left; }
.catalog-footer .fine-print { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; color: var(--muted); }

/* ---------- Full-screen views ---------- */
.screen {
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 45;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
}
.screen.cart-screen { z-index: 51; }

.screen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--stone);
}
.screen-header.cart-header { padding: 14px 16px; }
.screen-header-title { font: 700 17px var(--font-display); }
.screen-header-meta {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--muted);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.screen-header-kicker { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 2px; }

.screen-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }

.detail-hero { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--img-bg); }

/* Product photos without a file yet */
.img-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted);
}

/* ---------- Detail image carousel ---------- */
.carousel { display: flex; flex-direction: column; gap: 8px; }
.carousel-stage { position: relative; touch-action: pan-y; }
.carousel-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--ink); background: var(--paper); color: var(--ink);
  font: 400 22px/1 var(--font-display); cursor: pointer; padding: 0 0 3px;
}
.carousel-arrow.prev { left: 8px; }
.carousel-arrow.next { right: 8px; }
.carousel-count {
  position: absolute; bottom: 8px; right: 8px; padding: 3px 7px;
  background: var(--paper); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--ink);
}
.carousel-thumbs { display: flex; gap: 8px; overflow-x: auto; }
.carousel-thumb {
  width: 56px; height: 56px; flex-shrink: 0; padding: 0; cursor: pointer;
  border: 1px solid var(--stone); background: var(--img-bg); opacity: 0.6;
}
.carousel-thumb img { width: 100%; height: 100%; object-fit: cover; }
.carousel-thumb.active { border-color: var(--ink); outline: 1px solid var(--ink); opacity: 1; }

.detail-title { font: 700 20px var(--font-display); margin: 0 0 4px; }
.detail-desc { font: 400 12px/1.4 var(--font-display); color: var(--ink-soft); margin: 0; }
.detail-dims { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

.opt-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 6px; }

.opt-row { display: flex; gap: 6px; }
.opt-btn {
  flex: 1;
  min-height: 40px;
  padding: 6px 4px;
  border: 1px solid var(--stone);
  background: transparent;
  color: var(--ink);
  font: 500 12px var(--font-display);
  cursor: pointer;
}
.opt-btn.thickness { font-family: var(--font-mono); font-size: 11px; text-align: center; }
.opt-btn.active { border-color: var(--ink); background: var(--ink); color: var(--paper); }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 36px;
  height: 36px;
  border: 1px solid var(--stone);
  outline: none;
  outline-offset: 3px;
  cursor: pointer;
  padding: 0;
}
.color-swatch.active { outline: 2px solid var(--ink); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--stone); padding: 6px 10px; color: var(--ink-soft); }

.order-block { border-top: 1px solid var(--stone); padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.qty-row { display: flex; align-items: center; justify-content: space-between; }
.stepper { display: flex; align-items: center; border: 1px solid var(--ink); }
.stepper button { width: 36px; height: 36px; border: none; background: transparent; cursor: pointer; font-family: var(--font-mono); font-size: 16px; }
.stepper .qty-value {
  width: 30px; text-align: center; font-family: var(--font-mono); font-size: 14px; font-weight: 600;
  border: none; background: transparent; padding: 0; color: var(--ink); -moz-appearance: textfield;
}
.stepper input.qty-value::-webkit-outer-spin-button,
.stepper input.qty-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input.qty-value:focus { outline: 1px solid var(--ink); }

.total-row { display: flex; align-items: baseline; justify-content: space-between; }
.total-row .total-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--muted); }
.total-row .total-value { font: 700 24px var(--font-mono); }

.btn {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  cursor: pointer;
  border-radius: 0;
  width: 100%;
  display: block;
  text-align: center;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn-add { height: 44px; }
.btn-download { height: 48px; }

/* ---------- Cart ---------- */
.cart-context {
  padding: 12px 16px;
  border-bottom: 1px solid var(--stone);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-soft);
  background: var(--surface-card);
}
.cart-items { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.cart-empty { font-family: var(--font-mono); font-size: 12px; color: var(--muted); padding: 32px 0; text-align: center; }

.cart-item { border: 1px solid var(--stone); padding: 12px 14px; display: flex; gap: 12px; }
.cart-item-img { width: 56px; height: 56px; flex-shrink: 0; object-fit: cover; background: var(--img-bg); }
.cart-item-img.img-placeholder { font-size: 7px; text-align: center; }
.cart-item-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cart-item-top { display: flex; justify-content: space-between; gap: 8px; }
.cart-item-name { font: 700 14px var(--font-display); }
.cart-item-remove { border: none; background: transparent; color: var(--muted); cursor: pointer; font-family: var(--font-mono); font-size: 11px; text-decoration: underline; flex-shrink: 0; }
.cart-item-summary { font-family: var(--font-mono); font-size: 10px; color: var(--muted); line-height: 1.5; }
.cart-item-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.cart-item-bottom .stepper { border: 1px solid var(--stone); }
.cart-item-bottom .stepper button { width: 28px; height: 28px; }
.cart-item-bottom .stepper .qty-value { width: 24px; font-size: 12px; font-weight: 400; }
.cart-item-line-total { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

.cart-footer { padding: 16px; border-top: 1px solid var(--ink); display: flex; flex-direction: column; gap: 12px; }
.cart-footer .total-row .total-label { font-size: 11px; }
.contact-fields { display: flex; flex-direction: column; gap: 8px; }
.contact-fields input {
  border: 1px solid var(--stone);
  padding: 10px 10px;
  font-family: var(--font-display);
  font-size: 14px;
  background: var(--paper);
  width: 100%;
}
.contact-hint { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }

/* ---------- Detail layout (one column on phones) ---------- */
.detail-layout { display: flex; flex-direction: column; gap: 14px; }
.detail-info { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- "Agregado al pedido" toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 16px; right: 16px; bottom: 16px;
  max-width: 420px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--paper); padding: 12px 14px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em;
  animation: toast-in 0.2s ease-out;
}
.toast-check { color: var(--lienzo); font-weight: 600; }
.toast-sub { font-size: 10px; opacity: 0.75; margin-top: 3px; }
.toast-link {
  background: transparent; color: var(--paper); border: 1px solid var(--paper);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 7px 10px; cursor: pointer; flex-shrink: 0;
}
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.cart-backdrop { display: none; }

/* ---------- Tablet ---------- */
@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
}

/* ---------- Desktop ---------- */
@media (min-width: 960px) {
  #app-shell { max-width: 1240px; }
  .site-header { padding: 12px 32px; }
  .logo-mark { width: 190px; }

  .catalog-intro { padding: 48px 32px 16px; max-width: 760px; }
  .catalog-intro h1 { font-size: 40px; }
  .catalog-intro p { font-size: 16px; }
  .section-head { padding: 32px 32px 4px; }
  .section-head h2 { font-size: 24px; }
  .section-sub { padding: 0 32px 8px; }
  .section-sub p { font-size: 14px; }
  .product-grid { padding: 12px 32px 48px; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 20px; }
  .product-grid.estampa-grid { grid-template-columns: repeat(5, minmax(0,1fr)); padding-bottom: 56px; }
  .product-card-body { padding: 12px 14px 14px; }
  .product-card-title { font-size: 15px; }
  .catalog-footer { padding: 24px 32px; }

  /* Product detail: carousel on the left, options on the right */
  .screen { max-width: none; }
  .screen-header, .screen-body {
    padding-left: max(32px, calc((100% - 1240px) / 2 + 32px));
    padding-right: max(32px, calc((100% - 1240px) / 2 + 32px));
  }
  .screen-body { padding-top: 32px; padding-bottom: 48px; }
  .detail-layout {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 48px; align-items: start;
  }
  .detail-media { position: sticky; top: 0; }
  .detail-info { gap: 22px; }
  .detail-title { font-size: 30px; margin-bottom: 8px; }
  .detail-desc, .detail-dims { font-size: 14px; }
  .carousel-thumb { width: 72px; height: 72px; }
  .opt-btn { min-height: 44px; font-size: 13px; }
  .opt-btn:hover:not(.active) { border-color: var(--ink); }
  .color-swatch:hover { outline: 1px solid var(--stone); }
  .color-swatch.active:hover { outline: 2px solid var(--ink); }
  .btn-add { height: 50px; font-size: 13px; }

  /* Cart opens as a side drawer over the page */
  .cart-backdrop {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(20, 22, 26, 0.35); cursor: pointer;
  }
  .screen.cart-screen {
    left: auto; right: 0; width: 460px; margin: 0;
    border-left: 1px solid var(--stone);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
  }
  .cart-screen .screen-header, .cart-screen .screen-body { padding-left: 20px; padding-right: 20px; }

  .toast { left: auto; right: 32px; bottom: 32px; margin: 0; }
}

/* ---------- Print order sheet ---------- */
#print-order { display: none; }
@media print {
  #app-shell > *:not(#print-order) { display: none !important; }
  #print-order { display: block !important; }
}
#print-order {
  padding: 40px;
  font-family: var(--font-display);
  color: var(--ink);
}
.print-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 24px;
}
.print-brand { font: 700 24px var(--font-display); text-transform: uppercase; }
.print-date { font-family: var(--font-mono); font-size: 11px; }
.print-client { font-family: var(--font-mono); font-size: 12px; margin-bottom: 20px; line-height: 1.6; }
.print-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-table thead tr { border-bottom: 1px solid var(--ink); }
.print-table th { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; padding: 8px 4px; }
.print-table th.al, .print-table td.al { text-align: left; }
.print-table th.ac, .print-table td.ac { text-align: center; }
.print-table th.ar, .print-table td.ar { text-align: right; }
.print-table tbody tr { border-bottom: 1px solid var(--stone); }
.print-table td { padding: 10px 4px; }
.print-table td.name { font-weight: 600; }
.print-table td.detail { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); }
.print-table td.qty { font-family: var(--font-mono); }
.print-table td.subtotal { font-family: var(--font-mono); }
.print-total-row { display: flex; justify-content: flex-end; margin-top: 20px; }
.print-total { font: 700 20px var(--font-mono); }
.print-note { margin-top: 40px; padding-top: 10px; border-top: 1px solid var(--stone); font-family: var(--font-mono); font-size: 10px; color: var(--ink-soft); }
