/* ==============================================================
   AZULEJO COLOURING · page styles
   File: /azulejo-colouring/azulejo-colouring.css
   Colours, font and buttons come from site.css.
   The "How it helps" section uses shared styles (site.css, section 13).
   The glaze colours live in azulejo-colouring.js (section 1).

   Sections:
     1  Layout and intro
     2  Pattern chooser
     3  The tile
     4  Tools: palette, actions, preview
     5  Your wall
   ============================================================== */


/* --------------------------------------------------------------
   1 · LAYOUT AND INTRO
   -------------------------------------------------------------- */
.studio {
  padding-block: clamp(1.5rem, 5vw, 3rem) clamp(3rem, 8vw, 5rem);
  background: linear-gradient(var(--c-sky-top), var(--bg));
}
.studio__intro { max-width: 44rem; margin-bottom: 1.5rem; }
.studio__title {
  margin-bottom: .35em;
  font-size: clamp(2.4rem, 1.6rem + 3vw, 4rem);
  font-weight: var(--weight-light);
  letter-spacing: -.025em;
}
.studio__lede {
  font-size: var(--step-1);
  font-weight: var(--weight-light);
  line-height: 1.45;
}

.studio__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-areas:
    "bench palette"
    "bench tools";
  grid-template-rows: auto 1fr;
  gap: 1.25rem clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  margin-top: 1.25rem;
}
.bench { grid-area: bench; }
.palette-box { grid-area: palette; }
.tools { grid-area: tools; }

/* On narrow screens: colours on top (and kept in view), then the tile, then the tools */
@media (max-width: 860px) {
  .studio__grid {
    grid-template-columns: 1fr;
    grid-template-areas: "palette" "bench" "tools";
    grid-template-rows: auto;
  }
  .palette-box {
    position: sticky;
    top: var(--header-h);
    z-index: 5;
  }
}

.studio-status {
  min-height: 1.65em;
  margin-top: 1rem;
  color: var(--muted);
}


/* --------------------------------------------------------------
   2 · PATTERN CHOOSER
   -------------------------------------------------------------- */
.patterns {
  margin: 0;
  padding: 0;
  border: 0;
}
.patterns legend {
  padding: 0;
  margin-bottom: .6rem;
  font-weight: var(--weight-strong);
}
.patterns__row {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}
.pattern-choice {
  position: relative;
  display: grid;
  justify-items: center;
  gap: .3rem;
  padding: .45rem .45rem .35rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  font-size: .85rem;
}
.pattern-choice input { position: absolute; opacity: 0; pointer-events: none; }
.pattern-choice svg { width: 64px; height: 64px; display: block; border-radius: 3px; }
.pattern-choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
.pattern-choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }


/* --------------------------------------------------------------
   3 · THE TILE
   -------------------------------------------------------------- */
.tile-frame {
  padding: clamp(.6rem, 2vw, 1rem);
  background: #E6E1D6;             /* a little grout around the tile */
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.tile {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  touch-action: manipulation;
}
.tile .region {
  cursor: pointer;
  transition: fill .35s ease;
  stroke: #2B3550;
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-opacity: .75;
}
.tile .region:hover { filter: brightness(.94); }
.tile .region:focus { outline: none; }
.tile .region:focus-visible { stroke: #D98C1E; stroke-width: 3; stroke-opacity: 1; }
.tile .glaze { pointer-events: none; }

.bench__hint {
  margin-top: .75rem;
  font-size: var(--step--1);
  color: var(--muted);
  text-align: center;
}


/* --------------------------------------------------------------
   4 · TOOLS: PALETTE, ACTIONS, PREVIEW
   -------------------------------------------------------------- */
.palette-box {
  padding: clamp(.9rem, 3vw, 1.25rem) clamp(1rem, 4vw, 1.75rem);
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
}

.tools {
  display: grid;
  gap: 1.25rem;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
}

.palette {
  margin: 0;
  padding: 0;
  border: 0;
}
.palette legend {
  padding: 0;
  margin-bottom: .6rem;
  font-weight: var(--weight-strong);
}
.palette__row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}
.swatch-choice {
  position: relative;
  display: grid;
  justify-items: center;
  gap: .2rem;
  width: 4.1rem;
  cursor: pointer;
  font-size: .75rem;
  text-align: center;
  color: var(--muted);
}
.swatch-choice input { position: absolute; opacity: 0; pointer-events: none; }
.swatch-choice .dot {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset -3px -4px 6px rgba(0, 0, 0, .18), inset 3px 3px 5px rgba(255, 255, 255, .35), 0 0 0 1px rgba(0, 0, 0, .12);
  transition: transform .2s ease;
}
.swatch-choice:has(input:checked) .dot {
  transform: scale(1.08);
  box-shadow: inset -3px -4px 6px rgba(0, 0, 0, .18), inset 3px 3px 5px rgba(255, 255, 255, .35), 0 0 0 3px var(--surface), 0 0 0 5px var(--text);
}
.swatch-choice:has(input:checked) { color: var(--text); font-weight: var(--weight-strong); }
.swatch-choice:has(input:focus-visible) .dot { outline: 3px solid var(--accent); outline-offset: 4px; }

@media (max-width: 480px) {
  .palette legend { margin-bottom: .35rem; font-size: .9rem; }
  .palette__row { gap: .2rem; flex-wrap: nowrap; justify-content: space-between; }
  .swatch-choice { width: auto; flex: 1 1 0; font-size: .62rem; }
  .swatch-choice .dot { width: 2.1rem; height: 2.1rem; }
}

.mirror {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
}
.mirror input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); margin: 0; }

.tools__actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.preview__label {
  margin-bottom: .5rem;
  font-size: var(--step--1);
  color: var(--muted);
}
.preview__svg {
  display: block;
  width: 100%;
  max-width: 16rem;
  height: auto;
  border-radius: 4px;
  background: #E6E1D6;
}


/* --------------------------------------------------------------
   5 · YOUR WALL
   -------------------------------------------------------------- */
.wall-section {
  margin-top: clamp(2.5rem, 6vw, 4rem);
}
.wall-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem 1rem;
  margin-bottom: .75rem;
}
.wall-section__title {
  font-size: var(--step-2);
}
.wall-section__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.wall-section__note { color: var(--muted); max-width: 40rem; }
.wall-section__note:empty { display: none; }

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 4px;
  margin-top: 1rem;
  padding: 4px;
  background: #D9D3C6;               /* grout */
  border-radius: 6px;
}
.wall:empty { display: none; }
.wall svg {
  display: block;
  width: 100%;
  height: auto;
}
.wall .is-new { animation: tile-in .7s cubic-bezier(.34, 1.4, .64, 1) both; }
@keyframes tile-in {
  from { transform: scale(.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.btn--small.is-armed { border-color: var(--danger); color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .wall .is-new { animation: none; }
  .tile .region { transition: none; }
}
