/* Sinterklaas-thema: sint (rood & goud), het paard (bruin),
   piet (roetveeg-grijs) en pepernoten (karamelbruin). */
:root {
  --bg: #fdf6ea;
  --card: #fffdf7;
  --ink: #3a2a1e;
  --muted: #8a7561;
  --line: #ecdfc8;

  --red: #b3261e;        /* mantel van de sint */
  --red-dark: #8f1d17;
  --gold: #d4a12a;       /* mijter, staf en kruis */
  --gold-ink: #3a2a1e;

  --horse: #6f4a2e;      /* het paard */
  --pepernoot: #b5793f;  /* pepernoten */
  --soot: #4a423c;       /* roetveeg van piet */

  --danger: #a3241c;
  --ok: #567a33;
  --accent: var(--red);
  --accent-ink: #fff6e9;
}

* { box-sizing: border-box; }

/* Zorg dat het hidden-attribuut altijd wint van display-regels zoals
   .account { display: flex }, zodat verborgen elementen echt verborgen zijn. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  line-height: 1.5;
  /* Nachthemel: van zwart naar diepblauw. */
  background-color: #000000;
  background-image: linear-gradient(180deg, #000000 0%, #152c68 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* Sterrenhemel, dynamisch gevuld vanuit app.js. */
.sterren {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.ster {
  position: absolute;
  border-radius: 50%;
}

@keyframes twinkel {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .ster { animation: twinkel 3s ease-in-out infinite alternate; }
}

/* --- kop --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  /* Van donkerrood opzij naar iets lichter rood in het midden. */
  background: linear-gradient(90deg, #651010 0%, #961717 50%, #651010 100%);
  color: #fff6e9;
  border-bottom: 4px solid var(--gold);
}

.topbar h1 {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 1.15rem;
  color: #fff6e9;
}

/* De mijter van Sinterklaas, in css getekend. */
.mijter {
  position: relative;
  display: inline-block;
  width: 24px;
  height: 28px;
  margin-right: 0.55rem;
  vertical-align: -6px;
  background: var(--red);
  border-top: 2px solid var(--gold);
  border-radius: 2px;
  clip-path: polygon(50% 0%, 100% 58%, 100% 100%, 0% 100%, 0% 58%);
}

.mijter::before,
.mijter::after { content: ""; position: absolute; background: var(--gold); }

.mijter::before { left: 50%; top: 7px; width: 3px; height: 13px; transform: translateX(-50%); }
.mijter::after { left: 50%; top: 11px; width: 12px; height: 3px; transform: translateX(-50%); }

.account { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: #ffe9cf; }

.topbar .link-button { color: #fff6e9; }

/* --- inhoud --- */

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  gap: 1.25rem;
  /* Niet uitrekken tot de onderkant: rijen houden hun eigen hoogte. */
  align-content: start;
  align-items: start;
}

/* Ruimte tussen De Grote Inspiratiezak en De zak van Sinterklaas. */
#app-view {
  display: grid;
  gap: 1.25rem;
}

/* --- straat met lichtjes onderaan de pagina --- */

.straat {
  position: relative;
  width: 100%;
  height: 88px;
  margin-top: 1.5rem;
  cursor: pointer;
  overflow: hidden;
}

.straat:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }

.straat-laag {
  position: absolute;
  inset: 0;
  background-repeat: repeat-x;
  background-position: bottom left;
  background-size: auto 100%;
}

/* De gele skyline achter de donkere; schijnt door de ramen heen. */
.straat-achtergrond {
  background-image: url("/img/footer-street-background.svg");
  opacity: 0;
  transition: opacity 1s ease;
}

.straat-voorgrond {
  background-image: url("/img/footer-street-foreground.svg");
}

.straat.is-aan .straat-achtergrond { opacity: 1; }

/* Zwarte balk onder de straat. */
.straat-voet {
  flex: none;
  width: 100%;
  height: 25px;
  background: #111111;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 2px 10px rgba(90, 60, 30, 0.05);
}

.card h2 { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.25rem; font-size: 1.05rem; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.card-head h2 { margin: 0; }
.card-head button { margin: 0; }

.muted { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }
.optional { font-weight: 400; color: var(--muted); }

label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.9rem 0 0.3rem; }

input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf7;
}

input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }

/* Knoppen: pepernoot-goud met donkere letters. */
button {
  margin-top: 1rem;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--gold-ink);
  background: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 7px;
  cursor: pointer;
}

button:hover { filter: brightness(1.07); }
button:disabled { opacity: 0.55; cursor: default; }

.link-button {
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--red);
  text-decoration: underline;
  font-weight: 500;
}

.link-button:hover { filter: none; text-decoration-thickness: 2px; }

.status { min-height: 1.2em; margin: 0.75rem 0 0; font-size: 0.9rem; color: var(--muted); }
.status.error { color: var(--danger); }
.status.success { color: var(--ok); }

/* --- lijst --- */

.items { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.75rem; }

.items li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.85rem;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
}

.item-main { min-width: 0; }
.item-desc { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.item-meta a { color: var(--red); }

.delete {
  margin: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  flex: none;
}

.delete:hover { background: var(--danger); color: #fff6e9; filter: none; }

/* Bewerken en terugzetten: de kleur van het paard. */
.edit,
.restore {
  margin: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  background: transparent;
  color: var(--horse);
  border: 1px solid var(--horse);
  border-radius: 6px;
}

.edit:hover,
.restore:hover { background: var(--horse); color: #fff6e9; filter: none; }

.item-actions {
  display: flex;
  gap: 0.5rem;
  flex: none;
}

.item-actions button { margin: 0; }

/* Inline bewerken op de beheerpagina */
.items li.is-bewerken {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.items li.is-bewerken .item-main { display: grid; }

.items li.is-bewerken label.klein {
  margin: 0.5rem 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.items li.is-bewerken .item-actions { justify-content: flex-end; margin-top: 0.85rem; }

.buy {
  margin: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  background: var(--gold);
  color: var(--gold-ink);
  border: 1px solid var(--gold);
  border-radius: 6px;
}

.buy:hover { filter: brightness(1.07); }

/* Items in de zak van Sinterklaas */
.items li.is-bought { border-left-color: var(--soot); }

.is-bought .item-desc {
  text-decoration: line-through;
  color: var(--muted);
}

.sack-summary { font-style: italic; }

/* --- popup --- */

.dialog {
  width: min(92vw, 460px);
  padding: 0;
  border: 2px solid var(--gold);
  border-radius: 12px;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 12px 40px rgba(60, 30, 10, 0.25);
}

.dialog::backdrop { background: rgba(58, 42, 30, 0.5); }

.dialog form { padding: 1.25rem; }

.dialog h2 { margin: 0; font-size: 1.1rem; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.dialog-actions button { margin: 0; }

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.secondary:hover { background: var(--bg); filter: none; }
