/* Blockwright — Rotary-Mat Block Board */

:root {
  --primary: #3f6d5a;
  --primary-deep: #2f5346;
  --secondary: #f4e7c8;
  --accent: #d96a4e;
  --mint: #e9f3ec;
  --mint-soft: #f2f7f2;
  --ink: #24352c;
  --ink-soft: #5b6f64;
  --card: #fdfbf6;
  --danger: #b04a33;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: var(--mint);
  color: var(--ink);
  min-height: 100vh;
}

.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}

.stack > * + * { margin-top: 12px; }

/* ---------- spool-rack header ---------- */
.spool-rack {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0 14px;
}
.spool {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 34px;
  flex: none;
}
.spool-cap {
  height: 6px;
  background: var(--primary-deep);
  border-radius: 2px;
}
.spool-thread {
  height: 26px;
  background: repeating-linear-gradient(
    to bottom,
    var(--secondary) 0 5px,
    var(--accent) 5px 7px
  );
  border-radius: 2px;
}
.brand {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary-deep);
  line-height: 1.1;
}
.rack-line {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.rack-line span { font-weight: 700; color: var(--primary); }

/* ---------- generic ---------- */
.tab-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.tab-sub {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.blocks-head, .mat-panel > .mat-inner { padding-top: 6px; }

.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost {
  background: transparent;
  color: var(--primary);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.btn.danger.ghost {
  color: var(--danger);
  box-shadow: inset 0 0 0 2px var(--danger);
}
.btn.sm { padding: 9px 12px; font-size: 0.85rem; flex: 1; }

.linkish {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}

/* ---------- add strip ---------- */
.add-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--primary-deep);
}
.add-strip:active { transform: translateY(1px); }
.strip-scissor {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 3px solid #fff;
  position: relative;
}
.strip-scissor::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 14px;
  background: #fff;
  transform: translate(-50%, -100%) rotate(40deg);
  border-radius: 3px;
}

/* ---------- board (Blockboard) ---------- */
.pinned-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.board-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--secondary);
  border-radius: 10px;
  padding: 10px 14px;
}
.board-fact { font-size: 0.88rem; font-weight: 700; color: var(--primary-deep); }

/* ---------- hexagonal patch tiles ---------- */
.hex {
  --clip: polygon(9% 0, 91% 0, 100% 50%, 91% 100%, 9% 100%, 0 50%);
  clip-path: var(--clip);
  background: repeating-linear-gradient(
    45deg,
    var(--primary) 0 7px,
    transparent 7px 13px
  );
  padding: 4px;
  margin-bottom: 14px;
}
.hex-compact { padding: 3px; }
.hex-in {
  clip-path: var(--clip);
  background: var(--card);
  display: flex;
  align-items: stretch;
  min-height: 86px;
}
.hex-compact .hex-in { min-height: 64px; }
.palette-strip { width: 12px; flex: none; }
.hex-body { flex: 1; padding: 12px 10px 12px 14px; min-width: 0; }
.hex-name {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--primary-deep);
  line-height: 1.2;
}
.hex-compact .hex-name { font-size: 0.98rem; }
.hex-palette {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hex-size {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}
.hex-compact .hex-size { margin-top: 2px; }
.hex-note {
  font-size: 0.82rem;
  color: var(--ink);
  margin-top: 6px;
  line-height: 1.45;
}
.hex-when {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 6px;
}
.hex-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding-right: 14px;
  flex: none;
}
.iconbtn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: none;
  background: var(--secondary);
  color: var(--primary-deep);
  font-size: 0.95rem;
  cursor: pointer;
}
.iconbtn.del { background: #f7e0d8; color: var(--danger); }

/* ---------- hex stack (Blocks tab) ---------- */
.hex-stack { margin-top: 12px; }

/* ---------- Cut mat panel ---------- */
.mat-panel {
  position: relative;
  background: var(--primary);
  border-radius: var(--radius);
  padding: 14px;
  overflow: hidden;
}
.mat-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.14) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.mat-inner {
  position: relative;
  background: var(--card);
  border-radius: 10px;
  padding: 16px;
}
.mat-inner .tab-title { color: var(--primary-deep); }

.field { margin-top: 14px; }
.flabel {
  display: block;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.req { color: var(--accent); }
.opt {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-soft);
}
.fin {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  width: 100%;
  border: 2px solid #d7e4db;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}
.fin:focus { border-color: var(--primary); }
textarea.ta { resize: vertical; min-height: 74px; line-height: 1.45; }
.ferr {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--danger);
  margin-top: 5px;
}
.form-row { display: flex; gap: 10px; margin-top: 18px; }
.form-row .btn.primary { flex: 1; }
.form-ok {
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--mint);
  border-radius: 8px;
  padding: 9px 12px;
}

/* ---------- Find tab ---------- */
.search-wrap { margin-top: 4px; }
.find-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.find-hint {
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: var(--secondary);
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.5;
}
.find-list { margin-top: 12px; }

.about-panel {
  margin-top: 20px;
  background: var(--card);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 16px;
}
.about-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-deep);
}
.about-line {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 8px;
  line-height: 1.5;
}
.about-line.stat { color: var(--primary); font-weight: 700; }
.about-panel .form-row { margin-top: 14px; }

/* ---------- empty states ---------- */
.empty {
  text-align: center;
  padding: 28px 12px;
}
.patch-cluster { display: inline-flex; gap: 6px; margin-bottom: 12px; }
.patch-cluster i {
  width: 22px;
  height: 22px;
  clip-path: polygon(9% 0, 91% 0, 100% 50%, 91% 100%, 9% 100%, 0 50%);
  display: block;
}
.patch-cluster i:nth-child(1) { background: var(--primary); }
.patch-cluster i:nth-child(2) { background: var(--secondary); transform: translateY(6px); }
.patch-cluster i:nth-child(3) { background: var(--accent); }
.empty-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-deep);
}
.empty-msg {
  font-size: 0.86rem;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 6px auto 16px;
  max-width: 300px;
}

/* ---------- bottom tab bar (rotary cutters) ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--mint-soft);
  border-top: 2px solid var(--secondary);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabbtn {
  flex: 1;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: none;
  border: none;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 4px;
  cursor: pointer;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.tabbtn .cutter {
  width: 26px;
  height: 26px;
  transition: transform 0.18s ease;
}
.tabbtn[aria-selected="true"] {
  color: var(--primary-deep);
  background: var(--secondary);
  box-shadow: 0 3px 8px rgba(47, 83, 70, 0.28);
  border-radius: 12px;
}
.tabbtn[aria-selected="true"] .cutter {
  transform: rotate(-10deg);
  color: var(--primary-deep);
}
.tabbtn[aria-selected="false"] .cutter { color: #93a89c; }
