/* Mat tiling calculator (artificial-boxwood-hedge-mat). A v2 day-surface
   component: tokens come from /css/gs-v2.css. */
.mt { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 2rem clamp(2.5rem, 5vw, 4.5rem); align-items: start; }

/* Drawing */
.mt-figure { margin: 0; }
.mt-canvas { position: relative; aspect-ratio: 16 / 10; background: rgba(255, 255, 255, 0.32); border: 1px solid var(--gs-line-day); }
.mt-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mt-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.25rem; margin-top: 0.75rem; font: 500 var(--gs-label)/1.5 var(--gs-font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gs-muted-day); }
.mt-key { display: inline-flex; align-items: center; gap: 0.5rem; }
.mt-key::before { content: ""; flex: none; width: 14px; height: 14px; }
.mt-key-full::before { background: #3f6b34 url(/images/fluid/boxwood.webp) center / cover; }
.mt-key-cut::before { background: repeating-linear-gradient(-45deg, rgba(236, 232, 223, 0.85) 0 1px, rgba(236, 232, 223, 0.2) 1px 4px), #3f6b34 url(/images/fluid/boxwood.webp) center / cover; outline: 1px dashed rgba(27, 29, 26, 0.75); outline-offset: -1px; }
.mt-scale { margin-left: auto; }

.mt-svg text { font-family: var(--gs-font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.mt-ground { stroke: rgba(27, 29, 26, 0.55); stroke-width: 1; }
.mt-ground-ticks { stroke: rgba(27, 29, 26, 0.25); stroke-width: 1; fill: none; }
.mt-face { fill: #1f2d1c; }
.mt-wall { fill: none; stroke: var(--gs-ink-day); stroke-width: 1.5; }
.mt-full, .mt-cut { fill: url(#mt-box); }
.mt-cut-mark { fill: url(#mt-hatch); stroke: rgba(245, 242, 235, 0.95); stroke-width: 1.25; stroke-dasharray: 4 3; }
.mt-hatch-bg { fill: rgba(236, 232, 223, 0.2); }
.mt-hatch-line { stroke: rgba(236, 232, 223, 0.7); stroke-width: 1.3; }
.mt-dim line, .mt-dim path { stroke: var(--gs-ink-day); stroke-width: 1; fill: none; }
.mt-dim .mt-ext { stroke: rgba(27, 29, 26, 0.35); }
.mt-dim text { fill: var(--gs-ink-day); paint-order: stroke fill; stroke: #ECE8DF; stroke-width: 6px; stroke-linejoin: round; }
.mt-empty { fill: var(--gs-muted-day); }

/* Panels fill the wall from the bottom-left corner: transform and opacity
   only, staggered along the diagonal. */
.mt-anim rect { animation: mtTile 0.7s var(--gs-ease) both; animation-delay: var(--d, 0ms); transform-box: fill-box; transform-origin: 0 100%; }
@keyframes mtTile { from { opacity: 0; transform: scale(0.82); } to { opacity: 1; transform: none; } }
.mt-pending .mt-tiles rect { opacity: 0; }

/* Controls */
.mt-form h3 { margin-bottom: 1.1rem; }
.mt-controls { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 1.15rem; }
.mt-controls:disabled { opacity: 0.6; }
.mt-dimset { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.35rem 1rem; }
.mt-dimset legend { float: left; padding: 0; font-size: 0.9375rem; font-weight: 600; }
.mt-pair { display: inline-flex; gap: 0.5rem; }
.mt-unit { position: relative; }
.mt-unit input { width: 6.4ch; min-height: 44px; padding: 0.4rem 2.1rem 0.4rem 0.55rem; font: 500 1rem/1 var(--gs-font-mono); color: var(--gs-ink-day); text-align: right; background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(27, 29, 26, 0.3); border-radius: var(--gs-radius); -moz-appearance: textfield; appearance: textfield; transition: border-color 0.2s; }
.mt-unit input::-webkit-inner-spin-button, .mt-unit input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.mt-unit input:hover { border-color: rgba(27, 29, 26, 0.55); }
.mt-unit input:focus { border-color: var(--gs-ink-day); }
.mt-unit label { position: absolute; right: 0.55rem; top: 50%; transform: translateY(-50%); font: 500 var(--gs-label)/1 var(--gs-font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gs-muted-day); pointer-events: none; }
.mt-dimset .gs-range { grid-column: 1 / -1; }
.mt-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem; }
.mt-field label { font-size: 0.9375rem; font-weight: 600; }
.mt-field select { min-height: 44px; padding: 0.4rem 2.2rem 0.4rem 0.7rem; font: 500 1rem/1 var(--gs-font-mono); color: var(--gs-ink-day); background-color: rgba(255, 255, 255, 0.55); border: 1px solid rgba(27, 29, 26, 0.3); border-radius: var(--gs-radius); -webkit-appearance: none; appearance: none; }
.mt-field select { background-image: linear-gradient(45deg, transparent 50%, var(--gs-ink-day) 50%), linear-gradient(135deg, var(--gs-ink-day) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.mt-field select:focus { border-color: var(--gs-ink-day); }
.mt-help { font-size: 0.8125rem; line-height: 1.55; color: var(--gs-muted-day); }

/* Readout */
.mt-readout { margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--gs-line-day); display: grid; gap: 1rem; }
.mt-cases { display: flex; align-items: baseline; gap: 0.6rem; font-size: 0.9375rem; color: var(--gs-muted-day); }
.mt-cases output { font-family: var(--gs-font-display); font-weight: 300; font-size: clamp(2.6rem, 4vw, 3.4rem); line-height: 1; color: var(--gs-ink-day); font-variant-numeric: tabular-nums; }
.mt-cost > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--gs-line-day); font-size: 0.9375rem; }
.mt-cost > div:first-child { border-top: 1px solid var(--gs-line-day); }
.mt-cost dt a { color: var(--gs-green-day); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.22em; text-decoration-color: rgba(30, 92, 53, 0.4); }
.mt-cost dt a:hover { text-decoration-color: currentColor; }
.mt-cost dt small { display: block; font-size: var(--gs-xs); color: var(--gs-muted-day); }
.mt-cost dd { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mt-cost output { font-weight: 600; }
.mt-note { font-size: 0.8125rem; line-height: 1.5; color: var(--gs-muted-day); }
.mt-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--gs-line-day); }
.mt-stats div { padding: 0.65rem 0.75rem 0 0; }
.mt-stats dt { font: 500 var(--gs-label)/1.4 var(--gs-font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--gs-muted-day); }
.mt-stats dd { margin-top: 0.3rem; font-family: var(--gs-font-display); font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mt-summary { font-size: 0.9375rem; line-height: 1.55; }
.mt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; }
.mt-actions[hidden] { display: none; }
.mt-actions .mt-mail { font-size: 0.9375rem; font-weight: 600; color: var(--gs-green-day); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.22em; padding: 0.4rem 0; }
.mt-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 1024px) {
  .mt { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .mt-canvas { aspect-ratio: 4 / 3; }
  .mt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mt-stats div { padding-bottom: 0.65rem; }
  .mt-scale { margin-left: 0; }
  .mt-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .mt-anim rect { animation: none; }
}
