/* Designer layout. Brand values come from theme.css variables. */

.designer-head h1 {
  font-family: var(--font-display);
  margin-bottom: 0;
}

.designer-head p {
  color: var(--color-muted);
  margin-top: 0.25rem;
}

.designer-layout {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  gap: calc(var(--space) * 1.5);
  align-items: start;
  margin-bottom: calc(var(--space) * 1.5);
}

@media (max-width: 1000px) {
  .designer-layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius);
  padding: var(--space);
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 calc(var(--space) * 0.75);
}

.panel h3 {
  font-size: 0.95rem;
  margin: calc(var(--space) * 0.75) 0 calc(var(--space) * 0.4);
}

#save-state {
  min-height: 1.4em;
}

#my-designs a {
  color: var(--color-ink);
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#my-designs .mthumb {
  width: 56px;
  height: auto;
  flex: none;
  border: 1px solid var(--color-card-edge);
  border-radius: 4px;
}

#btn-save.dirty {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
  font-weight: 600;
}

/* Templates picker: same rows as My designs; Load button pinned right. */
#template-list li span {
  overflow-wrap: anywhere;
  margin-right: 0.5rem;
}

#template-list .mini-btn { flex: none; }

.field { margin-bottom: calc(var(--space) * 0.75); }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

#price-est {
  align-self: center;
  font-weight: 600;
  margin-right: auto;
}

.field select,
.field textarea,
.field input[type="text"],
.field input[type="email"],
.field input[type="number"] {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-card-edge);
  border-radius: 6px;
  font: inherit;
  background: var(--color-bg);
  color: var(--color-ink);
}

.canvas-area { min-width: 0; }

.face-tabs { margin-bottom: calc(var(--space) * 0.5); }

.face-tab {
  font: inherit;
  padding: 0.35rem 1rem;
  border: 1px solid var(--color-card-edge);
  background: var(--color-surface);
  color: var(--color-ink);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
}

.face-tab.active {
  background: var(--color-ink);
  color: var(--color-bg);
  border-color: var(--color-ink);
}

.face-tab:disabled { opacity: 0.4; cursor: default; }

.canvas-frame {
  /* Textured tabletop so cut-through reads as a real hole.
   * Swap wood-table.jpg for a photo anytime; no code changes needed. */
  background: #141210 url('../img/wood-table.jpg') center / cover;
  border: 1px solid var(--color-card-edge);
  border-radius: var(--radius);
  padding: calc(var(--space) * 1.5);
}

#card-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
}

.hint { color: var(--color-muted); font-size: 0.85rem; }

.layer-actions { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }

.layer-toolbar { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }

.layer-toolbar button { flex: 1; }

.align-row { display: flex; gap: 0.35rem; }

.align-btn { flex: 1; padding: 0.3rem 0.2rem; font-size: 0.8rem; }

.align-btn.active {
  background: var(--color-ink);
  color: var(--color-bg);
  border-color: var(--color-ink);
}

button:disabled { opacity: 0.35; cursor: default; }

button:disabled:hover { border-color: var(--color-card-edge); }

button {
  font: inherit;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--color-card-edge);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-ink);
  cursor: pointer;
}

button:hover { border-color: var(--color-accent); }

.layer-list { list-style: none; margin: 0 0 0.75rem; padding: 0; }

.layer-list li {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-rule);
  border-radius: 6px;
  margin-bottom: 0.35rem;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.layer-list li.selected {
  border-color: var(--color-accent);
  background: var(--color-bg);
}

.layer-list .mini-btn {
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

.layer-editor:empty { display: none; }

.layer-editor {
  border-top: 1px solid var(--color-rule);
  padding-top: 0.75rem;
}

.designer-foot {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: calc(var(--space) * 2);
}

.qty-field {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.qty-field input {
  width: 5.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-card-edge);
  border-radius: 6px;
  font: inherit;
  background: var(--color-bg);
  color: var(--color-ink);
}

#stock-note { font-size: 0.85rem; }

.gal-open { margin-top: 0.4rem; width: 100%; }

/* ---------- font gallery ---------- */

.font-veil {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.72);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space);
}

/* Author display:flex beats the UA [hidden] rule, so veils would show
   on page load. This keeps hidden working for every veil. */
.font-veil[hidden] { display: none !important; }

.gal-panel {
  background: var(--color-bg);
  border: 1px solid var(--color-card-edge);
  border-radius: var(--radius);
  max-width: 1100px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gal-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--color-rule);
}

.gal-head h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0;
  white-space: nowrap;
}

.gal-head input[type="search"] {
  flex: 1;
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-card-edge);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-ink);
}

.gal-close { flex: none; }

.gal-note { margin: 0; padding: 0.5rem 1.1rem 0; }

.gal-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-rows: max-content;
  gap: 0.9rem;
  padding: 1.1rem;
}

.gal-tile {
  /* Transparent wrapper: the card carries its own border + corners so
   * tiles preview the true card shape; the name floats free below. */
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  /* Grid auto-rows mis-resolved shorter than content in the wild
   * (128px row vs 193px content), clipping canvas bottoms. Force the
   * item — and therefore its row — to content height. Grid still
   * scrolls internally when rows exceed the panel. */
  min-height: max-content;
}

.gal-tile:hover canvas { border-color: var(--color-accent); }

.gal-tile canvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--color-card-edge);
  border-radius: 10px;
  /* Hard-lock the card ratio: deterministic even if intrinsic sizing
   * ever mis-reports (the tile grid once resolved rows at 128px for
   * 193px of content with no constraining rule in sight). */
  aspect-ratio: 344 / 216;
  display: block;
}

.gal-tile.loading canvas {
  min-height: 120px;
  background: linear-gradient(100deg, var(--color-rule) 40%, var(--color-bg) 50%, var(--color-rule) 60%);
  background-size: 200% 100%;
  animation: gal-shimmer 1.2s infinite linear;
}

@keyframes gal-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.gal-name {
  padding: 0.35rem 0.2rem 0;
  font-size: 0.85rem;
  color: var(--color-muted);
  border-top: none;
  text-align: center;
}

@media (max-width: 640px) {
  .font-veil { padding: 0; }
  .gal-panel { max-height: 100vh; height: 100%; border-radius: 0; }
  .gal-grid { grid-template-columns: 1fr 1fr; }
  .gal-head h2 { display: none; }
}
