/* Piana Surfaces slab calculator (slab-calculator.html). Uses the tokens in styles.css. */

.pl { padding-bottom: 72px; }
.pl[hidden] { display: none; }

.pl-grid { display: grid; gap: 0; }
@media (min-width: 1024px) {
  .pl-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 64px; align-items: start; }
  .pl-side { position: sticky; top: calc(var(--header-h) + 24px); padding-top: 40px; }
}

.pl-step { padding: 40px 0; border-top: 1px solid var(--line); }
.pl-step:first-child { border-top: 0; padding-top: 8px; }
.pl-step .label { margin-bottom: 10px; }
.pl-step h2 { font-size: clamp(1.625rem, 3vw, 2.25rem); }
.pl-h3 { font-family: var(--head); font-weight: 400; font-size: 1.25rem; margin: 0 0 6px; }
.pl-hint { margin: 10px 0 18px; color: var(--muted); font-size: 15px; max-width: 40em; }
.pl-small { margin: 28px 0 0; color: var(--muted); font-size: 13px; max-width: 46em; }
.pl-empty { color: var(--muted); padding: 20px 0; margin: 0; }
.pl-warn { margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--error); color: var(--error); font-size: 14px; }

.pl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.pl-units .chip { min-height: 32px; padding: 4px 12px; font-size: 13px; }

/* Pieces */
.pl-piece { border: 1px solid var(--line); padding: 16px; margin-bottom: 12px; background: var(--bg); }
.pl-piece-head { display: flex; gap: 10px; align-items: center; }
.pl-piece-head .pl-name { flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; font-family: var(--head); font-size: 17px; }
.pl-remove,
.pl-textbtn {
  flex: none; padding: 8px 4px; border: 0; background: none; color: var(--muted); cursor: pointer;
  font-family: var(--head); font-weight: 500; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  text-decoration: underline; text-underline-offset: 4px;
}
.pl-remove:hover, .pl-textbtn:hover { color: var(--ink); }

.pl-dims { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 10px; margin-top: 12px; }
.pl-numf { display: block; min-width: 0; }
.pl-numf > span:first-child,
.pl-wfh > span:first-child { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
.pl-inp { position: relative; display: block; }
.pl input[type="number"] {
  display: block; width: 100%; min-height: 46px; padding: 10px 38px 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.3; -moz-appearance: textfield; appearance: textfield;
}
.pl input[type="number"]::-webkit-outer-spin-button,
.pl input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pl-qty input[type="number"] { padding-right: 12px; }
.pl-u { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }

.pl-edges {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: ". b ." "l s r" ". f ."; gap: 8px 10px; align-items: center; margin-top: 16px;
}
.pl-edge { display: block; min-width: 0; }
.pl-edge span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.pl-edge select { min-height: 40px; padding: 7px 30px 7px 10px; font-size: 14px; background-position: right 10px center; }
.pl-edge-b { grid-area: b; } .pl-edge-f { grid-area: f; } .pl-edge-l { grid-area: l; } .pl-edge-r { grid-area: r; }
.pl-edge-b, .pl-edge-f { width: min(100%, 200px); justify-self: center; }
.pl-shape { grid-area: s; display: block; justify-self: center; background: #F6F6F6; box-sizing: border-box; }
.pl-edges { max-width: 520px; }
@media (max-width: 559px) {
  .pl-edges { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "b f" "l r"; }
  .pl-shape { display: none; }
  .pl-edge-b, .pl-edge-f { width: auto; justify-self: stretch; }
}
.pl-wf { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.pl-wf[hidden] { display: none; }

.pl-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 8px; }
.pl-row-actions .btn { min-height: 46px; padding: 10px 22px; }

.pl-edgebox { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.pl-edgebox .pl-hint { margin: 4px 0 14px; }
.pl-other { display: inline-flex; align-items: center; gap: 6px; cursor: text; }
.pl-other input[type="number"] {
  width: 64px; min-height: 26px; padding: 2px 4px; border: 0; border-bottom: 1px solid var(--line-strong);
  background: transparent; font-size: 14px; text-align: right;
}
.pl-other input[type="number"]:focus { outline: none; border-bottom-color: var(--ink); }
.pl-wfh { display: grid; grid-template-columns: 1fr; gap: 6px; max-width: 320px; margin-top: 20px; }
.pl-wfh .pl-hint { margin: 0; font-size: 13px; }

/* Results */
.pl-results { padding: 32px 0 8px; border-top: 1px solid var(--line); }
@media (min-width: 1024px) { .pl-results { padding: 28px; border: 1px solid var(--line); } }
.pl-results .label { margin-bottom: 6px; }
.pl-big { display: flex; align-items: baseline; gap: 12px; margin: 0; }
.pl-big-n { font-family: var(--head); font-weight: 300; font-size: clamp(4rem, 9vw, 5.5rem); line-height: 1; letter-spacing: -0.02em; }
.pl-big-u { font-family: var(--head); font-weight: 300; font-size: 1.75rem; }
.pl-big-sub { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.pl-facts { margin: 22px 0 0; display: grid; gap: 0; }
.pl-facts div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.pl-facts dt { color: var(--muted); font-size: 14px; }
.pl-facts dd { margin: 0; text-align: right; font-family: var(--head); font-size: 1.125rem; }
.pl-facts dd span { display: block; font-family: var(--body); font-size: 12px; color: var(--muted); }
.pl-how { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 14px; color: var(--muted); }
.pl-how summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.pl-how p { margin: 10px 0 0; }
.pl-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.pl-actions .btn { flex: 1 1 180px; min-height: 48px; padding: 12px 18px; }
.pl-status { margin: 10px 0 0; font-size: 14px; }
.pl-status:empty { display: none; }

/* Slab picker */
.pl-pick {
  display: grid; grid-auto-flow: column; grid-auto-columns: 116px; gap: 8px;
  overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 10px; margin: 0 -2px;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 720px) {
  .pl-pick { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); overflow: visible; }
}
.pl-swatch {
  display: flex; flex-direction: column; gap: 6px; padding: 4px 4px 8px; scroll-snap-align: start;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer;
  font-family: var(--body); font-size: 13px; line-height: 1.25; text-align: left;
}
.pl-swatch img { width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; }
.pl-swatch span { padding: 0 2px; }
.pl-swatch:hover { border-color: var(--line-strong); }
.pl-swatch[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.pl-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin: 22px 0 6px; }
.pl-slabname { margin: 0; font-family: var(--head); font-size: 1.25rem; }
.pl-slabname a { text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.pl-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.pl-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.pl-toolbtns { display: flex; gap: 8px; }
.pl-draghint { margin: 4px 0 18px; font-size: 14px; }
.pl-mini {
  min-height: 36px; padding: 6px 12px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); cursor: pointer;
  font-family: var(--head); font-weight: 500; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
}
.pl-mini:hover { border-color: var(--ink); }
.pl-mini[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
@media (hover: hover) and (pointer: fine) { .pl-touch-only { display: none; } }

/* Slabs */
.pl-slabs { display: grid; gap: 36px; }
.pl-slab { margin: 0; }
.pl-cv { position: relative; width: 100%; aspect-ratio: 2 / 1; background: #F2F2F2; }
.pl-cv canvas { display: block; width: 100%; height: 100%; touch-action: pan-y pinch-zoom; }
.pl-cv canvas:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.pl-slabs.is-moving canvas { touch-action: none; }
.pl-slab figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0 4px; }
.pl-slab-t { font-family: var(--head); font-size: 1.125rem; }
.pl-slab-u { font-size: 14px; color: var(--muted); }
.pl-cuts { list-style: none; margin: 0; padding: 0; }
.pl-cuts li {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px;
}
@media (min-width: 640px) { .pl-cuts li { grid-template-columns: auto minmax(0, 1fr) auto; } }
.pl-cuts li.is-sel { background: #F7F7F7; box-shadow: -8px 0 0 #F7F7F7, 8px 0 0 #F7F7F7; }
.pl-cuts li.is-bad .pl-cn span { color: var(--error); }
.pl-no {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 999px; background: var(--ink); color: #FFFFFF; font-size: 12px; font-weight: 500;
}
.pl-cn b { font-weight: 500; }
.pl-cn span { display: block; color: var(--muted); font-size: 13px; }
.pl-ca { display: flex; gap: 6px; grid-column: 2; }
@media (min-width: 640px) { .pl-ca { grid-column: auto; } }
.pl-move { width: auto; min-height: 36px; padding: 4px 30px 4px 10px; font-size: 13px; background-position: right 10px center; }

.pl-notes { margin-top: 28px; }
.pl-notes ul { margin: 8px 0 0; padding-left: 1.1em; color: var(--muted); font-size: 14px; max-width: 46em; }
.pl-notes li { margin-bottom: 6px; }

/* Bar on phones: the count stays in view while you edit */
.pl-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line); font-family: var(--head); font-size: 16px;
}
.pl-bar[hidden] { display: none; }
.pl-bar a { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; text-decoration: none; border-bottom: 1px solid var(--ink); padding-bottom: 2px; }
@media (min-width: 1024px) { .pl-bar { display: none !important; } }

@media print {
  .site-header, .site-footer, .cta, .pl-pick, .pl-tools, .pl-draghint, .pl-bar, .pl-actions, .pl-ca, .pl-remove, .pl-row-actions { display: none !important; }
  .pl-side { position: static; }
}
