/* ============================================================================
   MESH TEXTURES, PRODUCT ILLUSTRATIONS, AND THE SIZE SCALER
   ========================================================================== */

/* --- Mesh swatches: the three window qualities, drawn in CSS -------------
   The cell size is what separates them — fibre glass is visibly finer.     */
.mesh {
  --cell: 7px;
  --thread: var(--mesh-line);
  background-image:
    linear-gradient(var(--thread) 1px, transparent 1px),
    linear-gradient(90deg, var(--thread) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}
.mesh.fine   { --cell: 5px;  --thread: rgba(255,255,255,.16); }
.mesh.medium { --cell: 8px; }
.mesh.coarse { --cell: 12px; }
[data-theme="light"] .mesh.fine { --thread: rgba(0,0,0,.20); }

.mesh-demo {
  display: flex; gap: 14px; margin: 20px 0; flex-wrap: wrap;
}
.mesh-demo figure { margin: 0; text-align: center; }
.mesh-demo .sq {
  width: 76px; height: 76px; border-radius: 10px;
  border: 1px solid var(--line); background-color: var(--surface-2);
  margin-bottom: 7px;
}
.mesh-demo figcaption { font-size: .74rem; color: var(--text-3); font-weight: 600; }

/* --- Product illustrations ---------------------------------------------- */
.illus svg { overflow: visible; }
.illus .stroke  { stroke: var(--accent); fill: none; stroke-width: 2.5;
                  stroke-linecap: round; stroke-linejoin: round; }
.illus .thin    { stroke: var(--text-3); fill: none; stroke-width: 1.4; }
.illus .fill    { fill: color-mix(in srgb, var(--accent) 15%, transparent); }
.illus .solid   { fill: var(--accent); }
.illus .dim     { fill: var(--text-3); font-size: 11px; font-weight: 700;
                  font-family: inherit; }

/* Mesh fill used inside illustrations */
.illus .netfill { fill: url(#netpat); }

/* Magnetic door: the two halves part and snap back */
.door-l, .door-r { transform-origin: center; }
.illus-door:hover .door-l,
.illus-door.play  .door-l { animation: partL 2.6s var(--ease) infinite; }
.illus-door:hover .door-r,
.illus-door.play  .door-r { animation: partR 2.6s var(--ease) infinite; }
@keyframes partL {
  0%, 18%   { transform: translateX(0) skewY(0deg); }
  42%, 58%  { transform: translateX(-26px) skewY(2.5deg); }
  86%, 100% { transform: translateX(0) skewY(0deg); }
}
@keyframes partR {
  0%, 18%   { transform: translateX(0) skewY(0deg); }
  42%, 58%  { transform: translateX(26px) skewY(-2.5deg); }
  86%, 100% { transform: translateX(0) skewY(0deg); }
}
.walker { opacity: 0; }
.illus-door:hover .walker,
.illus-door.play  .walker { animation: walk 2.6s var(--ease) infinite; }
@keyframes walk {
  0%, 12%  { opacity: 0; transform: translateX(-30px) scale(.9); }
  32%, 62% { opacity: 1; transform: translateX(0) scale(1); }
  84%, 100%{ opacity: 0; transform: translateX(34px) scale(1.08); }
}
.snap { opacity: 0; }
.illus-door:hover .snap,
.illus-door.play  .snap { animation: snap 2.6s var(--ease) infinite; }
@keyframes snap { 0%, 80% { opacity: 0; } 88% { opacity: 1; } 100% { opacity: 0; } }

/* Cradle swing */
.cradle-body { transform-origin: 50% 8%; animation: rock 3.4s ease-in-out infinite; }
@keyframes rock { 0%, 100% { transform: rotate(-3.5deg); } 50% { transform: rotate(3.5deg); } }

/* Well ripple */
.ripple { transform-origin: center; animation: ripple 3.6s ease-out infinite; }
.ripple:nth-of-type(2) { animation-delay: 1.2s; }
.ripple:nth-of-type(3) { animation-delay: 2.4s; }
@keyframes ripple {
  0%   { transform: scale(.35); opacity: .8; }
  100% { transform: scale(1.05); opacity: 0; }
}

/* Birthday sparkle */
.sparkle { animation: twinkle 2.2s ease-in-out infinite; transform-origin: center; }
.sparkle:nth-of-type(2) { animation-delay: .5s; }
.sparkle:nth-of-type(3) { animation-delay: 1.1s; }
.sparkle:nth-of-type(4) { animation-delay: 1.6s; }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.1); } }

@media (prefers-reduced-motion: reduce) {
  .cradle-body, .ripple, .sparkle,
  .illus-door .door-l, .illus-door .door-r, .walker, .snap { animation: none; }
  .walker, .snap { opacity: 1; }
  .ripple { opacity: .35; }
  .sparkle { opacity: .8; }
}

/* ============================================================================
   SIZE SCALER
   ========================================================================== */

.scaler {
  display: grid; gap: 30px;
  grid-template-columns: 1.25fr .95fr;
  align-items: start;
}

.stage {
  position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.stage svg { width: 100%; height: auto; display: block; }

.room-wall  { fill: var(--surface-2); }
.room-floor { fill: var(--surface-3); }
.room-line  { stroke: var(--line); stroke-width: 1.5; fill: none; }
.person     { fill: var(--text-3); opacity: .55; }
.person-lbl { fill: var(--text-3); font-size: 10px; font-weight: 700; }

.net-panel {
  fill: url(#meshpat);
  stroke: var(--red); stroke-width: 2.5;
  transition: x .45s var(--ease), y .45s var(--ease),
              width .45s var(--ease), height .45s var(--ease);
}
.net-glow { filter: drop-shadow(0 0 12px var(--red-glow)); }
.allowance {
  fill: none; stroke: var(--red-bright); stroke-width: 1.5;
  stroke-dasharray: 5 4; opacity: 0;
  transition: all .45s var(--ease), opacity .3s;
}
.allowance.on { opacity: .9; }

.dim-line  { stroke: var(--red); stroke-width: 1.5; }
.dim-tick  { stroke: var(--red); stroke-width: 1.5; }
.dim-text  {
  fill: var(--text); font-size: 12px; font-weight: 800;
  font-family: inherit; font-variant-numeric: tabular-nums;
}

.controls {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px;
}

.ctl { margin-bottom: 22px; }
.ctl > label,
.ctl > .lbl {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
  font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
}
.ctl output {
  font-size: 1.02rem; font-weight: 900; color: var(--red-text);
  letter-spacing: -.01em; text-transform: none;
  font-variant-numeric: tabular-nums;
}
.ctl output small { color: var(--text-3); font-weight: 600; font-size: .78rem; }

input[type="range"] {
  width: 100%; height: 32px; margin: 0; background: transparent;
  -webkit-appearance: none; appearance: none; cursor: grab;
}
input[type="range"]:active { cursor: grabbing; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 100px;
  background: linear-gradient(90deg, var(--red) var(--fill, 0%), var(--surface-3) var(--fill, 0%));
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 100px; background: var(--surface-3);
}
input[type="range"]::-moz-range-progress {
  height: 6px; border-radius: 100px; background: var(--red);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -8px;
  border-radius: 50%; background: var(--red);
  border: 3px solid var(--surface);
  box-shadow: 0 2px 10px var(--red-glow);
  transition: transform .15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--red); border: 3px solid var(--surface);
  box-shadow: 0 2px 10px var(--red-glow);
}

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg-2); color: var(--text-2);
  font-size: .82rem; font-weight: 700; cursor: pointer;
  transition: all .2s;
}
.seg button:hover { border-color: var(--red); color: var(--text); }
.seg button[aria-pressed="true"] {
  background: var(--red); border-color: var(--red); color: #fff;
}

.check {
  display: flex; align-items: center; gap: 11px; cursor: pointer;
  font-size: .88rem; color: var(--text-2); user-select: none;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 21px; height: 21px; flex-shrink: 0; border-radius: 6px;
  border: 1.5px solid var(--line); background: var(--bg-2);
  display: grid; place-items: center;
  transition: all .2s;
}
.check .box svg { width: 12px; height: 12px; opacity: 0; color: #fff; }
.check input:checked + .box { background: var(--red); border-color: var(--red); }
.check input:checked + .box svg { opacity: 1; }
.check input:focus-visible + .box { outline: 2px solid var(--red-bright); outline-offset: 2px; }

.readout {
  padding: 20px; margin: 22px 0 18px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.readout .size-big {
  font-size: 1.5rem; font-weight: 900; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.readout .size-cm { font-size: .86rem; color: var(--text-3); margin-bottom: 14px; }
.readout .approx {
  display: inline-block; margin-top: 8px; padding: 4px 10px; border-radius: 6px;
  background: var(--red-wash); border: 1px solid var(--red);
  font-size: .74rem; font-weight: 700; color: var(--red-text);
}

@media (max-width: 900px) {
  .scaler { grid-template-columns: 1fr; }
}
