/* ============================================================
   Terraco visualizer — tokens + layout
   Ported from plans/design/index.html. Minimal chrome only:
   no nav, no breadcrumb, no footer. Square (1:1) imagery.
   ============================================================ */

:root {
  --brand:      #1a4287;
  --brand-deep: #122e60;
  --brand-ink:  #0c1f43;
  --ink:        #181613;
  --ink-2:      #3a3530;
  --muted:      #7a7167;
  --line:       #e6dfd2;
  --line-2:     #efe9dc;
  --bg:         #faf6ee;
  --bg-2:       #f3ecde;
  --surface:    #ffffff;
  --accent:     #b88146;
  --danger:     #b2422a;
  --ok:         #2e6f3f;

  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans:  "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --shadow-sm: 0 1px 2px rgba(18,46,96,.06), 0 2px 6px rgba(18,46,96,.04);
  --shadow-md: 0 10px 30px -12px rgba(18,46,96,.18), 0 4px 12px rgba(18,46,96,.06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ============ Minimal header ============ */
.site-header {
  background: var(--brand);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.site-header .logo img { height: 26px; width: auto; filter: brightness(0) invert(1); }
.header-titles { display: flex; flex-direction: column; gap: 2px; line-height: 1.15; }
.header-titles .eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 600;
  color: rgba(255,255,255,.78);
}
.header-titles .site-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(22px, 2.4vw, 30px);
  margin: 0;
  letter-spacing: -.005em;
}

/* ============ Lede ============ */
.lede-section {
  max-width: 1320px;
  margin: 28px auto 0;
  padding: 0 28px;
}
.lede {
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.65;
  max-width: 64ch;
  margin: 0;
}
.lede b { color: var(--ink); font-weight: 600; }

/* ============ Surface picker (above visualizer) ============ */
.surface-picker-section {
  max-width: 1320px;
  margin: 18px auto 0;
  padding: 0 28px;
}
.surface-picker-section .section-title { margin-bottom: 10px; }
.surface-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.surface-chip-row .chip { font-size: 13.5px; padding: 8px 14px; display: inline-flex; align-items: center; gap: 6px; }
.surface-chip-row .chip-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--line-2);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 4px;
}
.surface-chip-row .chip.is-active .chip-badge { background: rgba(255,255,255,.18); color: #fff; }

/* ============ Visualizer ============ */
.visualizer {
  max-width: 1320px;
  margin: 22px auto 60px;
  padding: 0 28px;
}
.vz-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.vz-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, .85fr);
  gap: 22px;
}

/* Preview */
.preview-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.preview { position: relative; }
.preview .img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.preview .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .25s ease;
}
.preview .img-wrap.is-missing::after {
  content: "Chưa có ảnh";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  color: rgba(0,0,0,.4);
  text-transform: uppercase;
  background: rgba(255,255,255,.45);
  backdrop-filter: blur(2px);
}
.preview-meta {
  position: absolute;
  left: 14px;
  bottom: 14px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  max-width: calc(100% - 28px);
}
.preview-meta .swatch-mini {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #c9a978;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  flex: none;
}
.preview-meta b { color: var(--ink); font-weight: 600; }
.preview-meta .code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
  margin-left: 2px;
}
.preview-meta .meta-style { margin-top: 2px; color: var(--muted); }

/* Section heading */
.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 12px;
  letter-spacing: -.005em;
}
.section-title .count {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  margin-left: 8px;
  font-weight: 500;
  vertical-align: 2px;
}

/* Slot thumbs — 4×2 grid (validation §5) */
.tex-section { display: flex; flex-direction: column; gap: 10px; }
.slot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
  transition: transform .15s ease, box-shadow .15s ease;
  isolation: isolate;
  padding: 0;
  width: 100%;
}
.thumb:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06), var(--shadow-md); }
.thumb .img-wrap { position: absolute; inset: 0; }
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb .img-wrap.is-missing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg,
    rgba(0,0,0,.04) 0 8px,
    rgba(0,0,0,.07) 8px 16px);
}
.thumb .thumb-tag {
  position: absolute;
  left: 8px;
  top: 7px;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(255,255,255,.88);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.thumb .thumb-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 10px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.55));
  z-index: 2;
  letter-spacing: .01em;
  text-align: left;
}
.thumb.is-active {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--brand),
    var(--shadow-md);
}

/* Color column */
.color-col {
  background: var(--bg);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

.color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.swatch {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: var(--c, #ccc);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  transition: transform .14s ease;
  padding: 0;
  width: 100%;
}
.swatch:hover { transform: scale(1.06); }
.swatch .num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  color: rgba(0,0,0,.55);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
  opacity: 0;
  transition: opacity .15s;
}
.swatch:hover .num,
.swatch.is-active .num { opacity: 1; }
.swatch.is-dark .num {
  color: rgba(255,255,255,.85);
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.swatch.is-active {
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.08),
    0 0 0 2px var(--bg),
    0 0 0 4px var(--brand);
}

/* a11y */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Responsive */
@media (max-width: 1100px) {
  .vz-grid { grid-template-columns: 1fr; }
  .color-col { order: 2; }
  .preview-col { order: 1; }
  .color-grid { grid-template-columns: repeat(10, 1fr); }
}
@media (max-width: 760px) {
  .site-header { padding: 14px 18px; }
  .lede-section, .visualizer { padding-left: 18px; padding-right: 18px; }
  .vz-card { padding: 14px; }
  .slot-grid { grid-template-columns: repeat(4, 1fr); }
  .color-grid { grid-template-columns: repeat(8, 1fr); }
  .header-titles .site-title { font-size: 22px; }
}
