/* BORGO — interfaccia: quasi tutta iconica, calda, discreta */

@font-face {
  font-family: 'Quicksand';
  src: url('../vendor/fonts/quicksand-500.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Quicksand';
  src: url('../vendor/fonts/quicksand-700.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('../vendor/fonts/fraunces-600italic.woff2') format('woff2');
  font-weight: 600; font-style: italic; font-display: swap;
}

:root {
  --ink: #4a3327;
  --cream: #faf3e3;
  --cream-90: rgba(250, 243, 227, 0.92);
  --terra: #c2684a;
  --sage: #71855f;
  --shadow: 0 6px 24px rgba(60, 35, 20, 0.22);
}

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

html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Quicksand', sans-serif;
  font-weight: 500;
  color: var(--ink);
  background: #7db4e0;
  user-select: none;
  -webkit-user-select: none;
}

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }

/* ---------- barra alta ---------- */
.topbar {
  position: fixed; top: 18px; left: 22px; right: 22px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.nameplate {
  display: flex; align-items: center; gap: 10px;
  background: var(--cream-90);
  border-radius: 18px;
  padding: 10px 18px 12px;
  box-shadow: var(--shadow);
}
.nameplate h1 {
  font-family: 'Fraunces', serif;
  font-style: italic; font-weight: 600;
  font-size: 27px; line-height: 1;
  cursor: text; outline: none;
  border-bottom: 2px dashed transparent;
  transition: border-color .25s;
}
.nameplate h1:hover, .nameplate h1:focus { border-color: rgba(194, 104, 74, 0.45); }
.nameplate input {
  font-family: 'Fraunces', serif; font-style: italic; font-weight: 600;
  font-size: 27px; color: var(--ink);
  background: transparent; border: none; outline: none;
  border-bottom: 2px solid var(--terra);
  width: 300px;
}

.controls { display: flex; gap: 10px; align-items: center; }

.iconbtn, .pillbtn {
  font-family: inherit; font-weight: 700; font-size: 13px;
  color: var(--ink);
  background: var(--cream-90);
  border: none; border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), background .2s;
}
.iconbtn { padding: 8px; border-radius: 12px; }
.iconbtn.big { padding: 10px; }
.pillbtn { padding: 10px 15px; }
.iconbtn:hover, .pillbtn:hover { transform: translateY(-2px) scale(1.04); background: var(--cream); }
.iconbtn:active, .pillbtn:active { transform: scale(0.96); }
.iconbtn:focus-visible, .pillbtn:focus-visible, .piece:focus-visible { outline: 2.5px solid var(--terra); outline-offset: 2px; }
.pillbtn.solid { background: var(--terra); color: var(--cream); text-decoration: none; }

.daywrap {
  display: flex; align-items: center; gap: 9px;
  background: var(--cream-90);
  border-radius: 14px; padding: 7px 12px;
  box-shadow: var(--shadow);
}
.daywrap .iconbtn { box-shadow: none; background: transparent; padding: 5px; }
#dayIcon { width: 20px; height: 20px; display: inline-block; }
#dayIcon svg { display: block; }

#dayScrub {
  -webkit-appearance: none; appearance: none;
  width: 170px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #1b2a52 0%, #8a6a8e 22%, #f2b8a0 27%, #7db4e0 40%, #5fa8e8 55%, #ffb26a 72%, #e86e52 77%, #2a2b58 84%, #1b2a52 100%);
  cursor: pointer;
}
#dayScrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--cream);
  border: 2.5px solid var(--terra);
  box-shadow: 0 2px 6px rgba(60,35,20,.35);
  cursor: grab;
}
#dayScrub::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--cream); border: 2.5px solid var(--terra);
  cursor: grab;
}

/* ---------- palette pezzi ---------- */
.palette {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; align-items: flex-end;
  background: var(--cream-90);
  border-radius: 20px; padding: 9px 12px;
  box-shadow: var(--shadow);
  max-width: min(92vw, 900px);
}
.piece {
  border: none; background: transparent; border-radius: 14px;
  padding: 5px 4px 3px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-family: inherit; font-size: 9.5px; font-weight: 700; color: var(--ink);
  opacity: .82;
  transition: transform .16s cubic-bezier(.34,1.56,.64,1), background .18s, opacity .18s;
}
.piece:hover { transform: translateY(-4px) scale(1.07); opacity: 1; }
.piece.sel {
  background: #f5e0c8;
  opacity: 1;
  transform: translateY(-4px);
  box-shadow: inset 0 0 0 2px var(--terra);
}
.piece canvas { display: block; }

.hint {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; color: rgba(250, 243, 227, 0.85);
  text-shadow: 0 1px 4px rgba(30, 20, 40, 0.5);
  pointer-events: none;
  white-space: nowrap;
}

/* ---------- toast ---------- */
#toast {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: var(--cream); color: var(--ink);
  font-weight: 700; font-size: 13.5px;
  padding: 10px 20px; border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s cubic-bezier(.34,1.56,.64,1);
  z-index: 30;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(40, 25, 35, 0.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 1; transition: opacity .25s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.panel {
  position: relative;
  background: var(--cream);
  border-radius: 22px;
  padding: 26px 28px 24px;
  width: min(430px, 92vw);
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(30, 15, 10, 0.4);
  transform: scale(1); transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.overlay.hidden .panel { transform: scale(.92); }
.panel h2 {
  font-family: 'Fraunces', serif; font-style: italic;
  font-size: 19px; margin: 14px 0 10px;
}
.panel h2:first-of-type { margin-top: 0; }
.closebtn {
  position: absolute; top: 12px; right: 16px;
  border: none; background: none; font-size: 26px; line-height: 1;
  color: var(--ink); opacity: .5; cursor: pointer;
}
.closebtn:hover { opacity: 1; }

.slotrow, .presetrow {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 12px;
  background: rgba(194, 104, 74, 0.07);
  margin-bottom: 7px;
}
.slotrow .slotname { flex: 1; font-size: 13.5px; }
.slotrow .slotname b { display: block; font-size: 14.5px; }
.slotrow .slotname small { opacity: .6; font-size: 11px; }
.minibtn {
  font-family: inherit; font-weight: 700; font-size: 12px;
  border: none; border-radius: 9px; padding: 7px 12px;
  cursor: pointer; background: var(--terra); color: var(--cream);
  transition: transform .12s;
}
.minibtn:hover { transform: scale(1.05); }
.minibtn.alt { background: var(--sage); }
.minibtn:disabled { opacity: .35; cursor: default; transform: none; }
.presetrow { cursor: pointer; border: none; width: 100%; font-family: inherit; text-align: left; }
.presetrow:hover { background: rgba(194, 104, 74, 0.16); }
.presetrow b { font-size: 14.5px; color: var(--ink); }
.presetrow span { font-size: 11.5px; opacity: .65; color: var(--ink); }
.ghostbtn {
  width: 100%; margin-top: 10px;
  font-family: inherit; font-weight: 700; font-size: 13px;
  background: none; border: 2px dashed rgba(74, 51, 39, 0.35);
  border-radius: 12px; padding: 10px; color: var(--ink);
  cursor: pointer; transition: border-color .2s;
}
.ghostbtn:hover { border-color: var(--terra); color: var(--terra); }

.cardpanel { width: min(560px, 94vw); text-align: center; }
.cardpanel img { width: 100%; border-radius: 10px; box-shadow: 0 8px 30px rgba(30,15,10,.3); margin-bottom: 16px; }

/* ---------- footer ---------- */
footer {
  position: fixed; left: 22px; bottom: 16px;
  display: flex; gap: 14px; align-items: baseline;
  font-size: 12px;
  z-index: 5;
}
footer a { color: rgba(250, 243, 227, 0.9); text-decoration: none; font-weight: 700; text-shadow: 0 1px 4px rgba(30,20,40,.5); }
footer a:hover { text-decoration: underline; }
footer .sig { color: rgba(250, 243, 227, 0.55); font-style: italic; font-family: 'Fraunces', serif; text-shadow: 0 1px 4px rgba(30,20,40,.5); }

@media (max-width: 1100px) {
  .nameplate h1, .nameplate input { font-size: 22px; }
  #dayScrub { width: 120px; }
  .pillbtn { font-size: 12px; padding: 9px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
