/* =========================================================
   Corked — Vinskap-app
   Farger inspirert av mørk eik, bordeaux og gyllen chardonnay
   ========================================================= */

:root {
  --bg:            #1a1512;
  --bg-raised:    #241c18;
  --panel:         #2e251f;
  --text:          #f3ece1;
  --text-dim:      #b7a99a;
  --border:        #3d3229;

  --red:           #b83446;           /* lysere, cartoon-bordeaux */
  --red-stroke:   #5e1722;
  --white:         #f2d675;           /* brighter chardonnay-gyllen */
  --white-stroke: #8a6c22;
  --empty-fill:    #2a2018;
  --empty-stroke:  #1a120c;
  --label-red:     #f4dcbf;
  --label-white:   #f7ecc5;
  --cork:          #c9a06a;
  --cork-stroke:   #6a4a26;
  --drink-now:     #ffb347;

  --accent:        #d7ae72;
  --accent-strong: #ecc890;

  --shadow-lg:     0 8px 24px rgba(0,0,0,0.4);
  --radius:        10px;
  --radius-sm:     6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  height: 100vh;
  overflow: hidden;      /* hele appen skal få plass uten scroll */
}
body {
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 14px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
  color: var(--accent-strong);
  font-weight: 600;
}
.brand .subtitle {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.stats .count {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--panel);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14px;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-btn:hover { color: var(--text); border-color: var(--accent); }
.filter-btn.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.actions button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.actions button:hover { background: var(--bg-raised); border-color: var(--accent); }

/* ---------- Cabinet / SVG ---------- */

.cabinet-wrap {
  flex: 1;
  min-height: 0;                /* slik at barnet kan begrenses */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px 16px;
  overflow: hidden;
}

#cabinet {
  height: 100%;                 /* fyll den tilgjengelige høyden */
  width: auto;
  max-width: 100%;
  display: block;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.45));
}

/* Slot: ingen transform på hover (fjerner vibrering).
   Cursor + filter er nok for feedback. */
.slot {
  cursor: pointer;
  transition: filter .15s;
}
.slot:hover { filter: brightness(1.25); }

/* Standardfarger — brukes for tomme plasser (empty-klasse settes eksplisitt) */
.slot .bottle-body,
.slot .bottle-neck {
  fill: var(--empty-fill);
  stroke: var(--empty-stroke);
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.slot .bottle-label { fill: var(--empty-fill); stroke: none; }
.slot .bottle-cork { fill: var(--empty-fill); stroke: var(--empty-stroke); stroke-width: 1; }
.slot .bottle-shine { fill: transparent; }

/* Tom plass: gjør den litt mindre prominent */
.slot.empty .bottle-body,
.slot.empty .bottle-neck {
  fill: transparent;
  stroke: rgba(255,255,255,0.10);
  stroke-dasharray: 2 2;
}
.slot.empty .bottle-cork,
.slot.empty .bottle-label { fill: transparent; stroke: none; }

/* Rødvin */
.slot.red .bottle-body,
.slot.red .bottle-neck {
  fill: var(--red);
  stroke: var(--red-stroke);
}
.slot.red .bottle-label { fill: var(--label-red); }
.slot.red .bottle-cork { fill: var(--cork); stroke: var(--cork-stroke); }
.slot.red .bottle-shine { fill: rgba(255,255,255,0.55); }

/* Hvitvin */
.slot.white .bottle-body,
.slot.white .bottle-neck {
  fill: var(--white);
  stroke: var(--white-stroke);
}
.slot.white .bottle-label { fill: var(--label-white); }
.slot.white .bottle-cork { fill: var(--cork); stroke: var(--cork-stroke); }
.slot.white .bottle-shine { fill: rgba(255,255,255,0.75); }

/* Over toppen (systemklokka er forbi «til år») — rød ring på korken */
.slot.past-prime .bottle-cork {
  fill: #e85a3c;
  stroke: #7a2a18;
}

/* Dimmed (filter aktivt) */
.slot.dimmed { opacity: 0.2; }

/* ---------- Tooltip ---------- */

.tooltip {
  position: fixed;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  max-width: 260px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 50;
}
.tooltip .tt-title {
  font-weight: 600;
  color: var(--accent-strong);
  margin-bottom: 4px;
}
.tooltip .tt-row { color: var(--text-dim); }
.tooltip .tt-row strong { color: var(--text); font-weight: 500; }

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.modal-panel.modal-small { width: min(380px, calc(100vw - 32px)); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-size: 17px;
  color: var(--accent-strong);
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.modal-footer .spacer { flex: 1; }

.btn-primary,
.btn-ghost,
.btn-danger {
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--panel); }
.btn-danger {
  background: transparent;
  color: #e06b72;
  border-color: #5d2a2e;
}
.btn-danger:hover { background: #3a1d21; color: #ff8a8f; }

/* ---------- Form ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: none;
  padding: 0;
  margin: 0;
}
.field[hidden] { display: none; }
.field legend,
.field > span {
  font-size: 13px;
  color: var(--text-dim);
  padding: 0;
  margin-bottom: 2px;
}
.field label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-right: 14px;
  cursor: pointer;
}
.field input[type="text"],
.field input[type="number"] {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
.field input[type="text"]:focus,
.field input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.field-years .year-row {
  display: flex;
  gap: 10px;
}
.field-years .year-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}
.field-years .year-row input[type="number"] {
  width: 100%;
}
.field-years .hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0 0;
  line-height: 1.35;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.swatch-red { background: var(--red); border-color: var(--red-glow); }
.swatch-white { background: var(--white); border-color: #b79a4c; }

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, color .12s, border-color .12s;
}
.tag:hover { color: var(--text); border-color: var(--accent); }
.tag.selected {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px;
    gap: 10px 14px;
  }
  .brand h1 { font-size: 18px; }
  .brand .subtitle { font-size: 11px; }
  .filters { order: 3; width: 100%; }
  .actions { margin-left: 0; }
  .actions button { padding: 7px 10px; font-size: 12px; }
  .stats .count { padding: 6px 10px; font-size: 13px; }

  .cabinet-wrap { padding: 12px 6px 32px; }
  #cabinet { width: 100%; }
  .modal-panel { border-radius: 0; max-height: 100vh; height: 100%; width: 100vw; }
}
