/* Gesta Maps — Dashboard */

:root {
  --paper:      #f3ecdd;
  --panel:      #fbf6ec;
  --panel-2:    #fffdf7;
  --sidebar-bg: #ece3d1;
  --user-bg:    #e7dcc7;
  --ink:        #241c14;
  --ink-soft:   #564c3d;
  --muted:      #8a7d66;
  --faint:      #b6a98e;
  --accent:      #8b2e3f;
  --accent-deep: #6e1e2f;
  --accent-soft: #f1dde0;
  --gold:        #a9854a;
  --line:       #d6c9b0;
  --line-soft:  #e6dcc6;
  --serif: "Fraunces", "Georgia", serif;
  --sans:  "Instrument Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:  "JetBrains Mono", "SF Mono", Menlo, monospace;
  --sh-sm: 0 1px 3px rgba(54,40,20,.09);
  --sh-md: 0 4px 18px -5px rgba(54,40,20,.20);
  --sh-lg: 0 18px 50px -18px rgba(54,40,20,.32);
  --radius: 14px;
  --ease-out: cubic-bezier(.25,.46,.45,.94);
  --ease-spring: cubic-bezier(.2,.7,.2,1);
}

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

html, body {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  opacity: .25; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

button { cursor: pointer; font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center;
  padding: 0 40px;
  height: 58px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--line);
  gap: 20px;
  position: sticky; top: 0; z-index: 10;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif); font-size: 22px; font-weight: 600;
  color: var(--ink); letter-spacing: -.01em;
}
.brand-mark {
  font-size: 26px; color: var(--accent);
  display: inline-block; line-height: 1;
  transition: transform .2s cubic-bezier(.2,.7,.2,1);
}
.brand:hover .brand-mark { transform: rotate(18deg) scale(1.1); }
.brand em { font-style: italic; font-weight: 500; color: var(--accent); }

.topbar-spacer { flex: 1; }

/* ── Language switch (mirrors studio) ── */
.lang-switch {
  display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden;
  background: rgba(255,253,247,.5);
}
.lang-switch button {
  border: none; background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 10.5px; padding: 4px 9px;
  transition: background .11s, color .11s;
}
.lang-switch button.active { background: var(--accent); color: #fdf6ee; }
.lang-switch button:not(.active):hover { background: var(--accent-soft); color: var(--accent); }

/* ── Account button ── */
.acct-wrap { display: flex; align-items: center; }

/* Guest-only note: lives on its own slim line under the topbar (out of the
   cramped header), aligned to the content column. Hidden once signed in. */
.guest-note {
  max-width: 1160px; margin: 0 auto; padding: 9px 40px 0;
  font-size: 11.5px; line-height: 1.3; color: var(--faint); text-align: right;
}
.guest-note[hidden] { display: none; }

.acct-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; border-radius: 20px;
  background: rgba(255,253,247,.5); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px;
  transition: border-color .11s, background .11s, transform .11s cubic-bezier(.2,.7,.2,1);
}
.acct-btn:hover { border-color: var(--accent); background: var(--panel-2); transform: translateY(-1px); }
.acct-ava {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fdf6ee;
  font-family: var(--serif); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ── Main layout ── */
.dash-body {
  max-width: 1160px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

.dash-hero {
  margin-bottom: 48px;
  animation: riseIn .5s .04s cubic-bezier(.25,.46,.45,.94) both;
}
.dash-hero h1 {
  font-family: var(--serif); font-size: 36px; font-weight: 600;
  letter-spacing: -.02em; line-height: 1.1; color: var(--ink);
}
.dash-hero h1 em { font-style: italic; color: var(--accent); }
.dash-hero p {
  margin-top: 10px; font-size: 15px; color: var(--ink-soft); max-width: 54ch;
}
.dash-hero-actions {
  margin-top: 22px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

/* Primary quick-map CTA — one click, no naming, straight into the studio. */
.quick-map-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px;
  background: var(--accent); color: #fdf6ee;
  border: none; border-radius: 11px;
  font-size: 14.5px; font-weight: 600; letter-spacing: .01em;
  box-shadow: var(--sh-md);
  transition: background .11s, transform .11s cubic-bezier(.2,.7,.2,1), box-shadow .2s;
}
.quick-map-btn span:first-child { font-size: 16px; line-height: 1; }
.quick-map-btn:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: var(--sh-lg); }
.quick-map-btn:active { transform: scale(.97); }

/* Secondary new-project action in the hero. */
.new-proj-btn.secondary {
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--line); box-shadow: none;
  padding: 10px 18px;
}
.new-proj-btn.secondary:hover {
  background: var(--panel-2); border-color: var(--accent); color: var(--accent);
  box-shadow: var(--sh-sm); transform: translateY(-1px);
}

/* ── Section header ── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  animation: riseIn .45s .1s cubic-bezier(.25,.46,.45,.94) both;
}
.section-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--faint);
}

/* ── New project button ── */
.new-proj-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--accent); color: #fdf6ee;
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
  box-shadow: var(--sh-sm);
  transition: background .11s, transform .11s cubic-bezier(.2,.7,.2,1), box-shadow .2s;
}
.new-proj-btn:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: var(--sh-md); }
.new-proj-btn:active { transform: scale(.97); }

/* ── Projects grid ── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  animation: riseIn .5s .18s cubic-bezier(.25,.46,.45,.94) both;
}

.proj-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--sh-sm);
  transition:
    border-color .11s,
    transform    .15s cubic-bezier(.2,.7,.2,1),
    box-shadow   .2s;
}
.proj-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--sh-md); }
.proj-card:active { transform: scale(.99); }

/* ── Map preview thumbnail ── */
.proj-card-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--paper);
  border-bottom: 1px solid var(--line-soft);
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  overflow: hidden;
}
.proj-card-img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  display: block;
}
.proj-card-ph {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(45deg, var(--panel) 0 10px, var(--paper) 10px 20px);
  color: var(--faint); font-size: 30px;
}

.proj-card-body {
  padding: 16px 20px 16px;
  display: flex; flex-direction: column; gap: 9px; flex: 1;
}
.proj-card-name {
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  color: var(--ink); line-height: 1.2;
  word-break: break-word;
}
.proj-card-meta {
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.proj-card-meta .bullet { color: var(--line); }
.proj-card-files { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.proj-file-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 7px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.proj-file-chip .fc-ico { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.proj-card-open {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 10.5px; color: var(--accent);
  display: flex; align-items: center; justify-content: space-between;
  opacity: 0;
  transition: opacity .15s;
}
.proj-card:hover .proj-card-open { opacity: 1; }

/* Empty state */
.dash-empty {
  grid-column: 1 / -1;
  padding: 48px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; color: var(--faint);
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.dash-empty-ico { font-size: 40px; font-family: var(--serif); opacity: .4; }
.dash-empty-title { font-size: 15px; font-weight: 500; color: var(--ink-soft); }
.dash-empty-sub { font-size: 12.5px; }
.dash-empty-cta {
  margin-top: 4px;
  padding: 8px 20px; background: var(--accent); color: #fdf6ee;
  border: none; border-radius: 9px; font-size: 13px; font-weight: 600;
  transition: background .11s, transform .11s cubic-bezier(.2,.7,.2,1);
}
.dash-empty-cta:hover { background: var(--accent-deep); transform: translateY(-1px); }

/* ── Proj card menu ── */
.proj-card-menu {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(251,246,236,.85); backdrop-filter: blur(2px);
  border: 1px solid var(--line-soft);
  color: var(--ink-soft); font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .11s, background .11s, color .11s;
}
.proj-card:hover .proj-card-menu { opacity: 1; }
.proj-card-menu:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ── Context menu (shared with studio) ── */
.ctx-menu {
  position: fixed; z-index: 200; min-width: 184px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--sh-lg); padding: 6px; overflow: hidden;
  animation: pop .12s cubic-bezier(.25,.46,.45,.94);
}
.ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; background: transparent; border-radius: 7px;
  font-size: 13px; color: var(--ink-soft); text-align: left;
  transition: background .11s, color .11s, transform .11s;
}
.ctx-item:hover { background: var(--accent-soft); color: var(--accent); transform: translateX(2px); }
.ctx-item.danger:hover { background: #fbeee9; color: #9a3a2d; }
.ctx-item .ci-ico { width: 16px; text-align: center; }
.ctx-sep { height: 1px; background: var(--line-soft); margin: 5px 4px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(36,28,20,.34); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn .14s ease-out;
}
.modal {
  width: 100%; max-width: 400px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--sh-lg);
  padding: 24px; animation: pop .18s cubic-bezier(.2,.7,.2,1);
}
.modal-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.modal-input {
  width: 100%; margin-top: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  transition: border-color .11s, box-shadow .2s;
}
.modal-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,46,63,.1); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.modal-btn {
  padding: 8px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--line);
  transition: background .11s, transform .11s;
}
.modal-cancel { background: transparent; color: var(--ink-soft); }
.modal-cancel:hover { background: rgba(0,0,0,.04); }
.modal-ok { background: var(--accent); color: #fdf6ee; border-color: var(--accent); }
.modal-ok:hover { background: var(--accent-deep); transform: translateY(-1px); }
.modal-ok.danger { background: #9a3a2d; border-color: #9a3a2d; }

/* ── Keyframes ── */
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop    { from { opacity: 0; transform: scale(.94) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .dash-body { padding: 28px 16px 60px; }
  .projects-grid { grid-template-columns: 1fr; }
  .guest-note { padding: 8px 16px 0; text-align: left; }
  .dash-hero-actions .quick-map-btn,
  .dash-hero-actions .new-proj-btn.secondary { flex: 1; justify-content: center; }
}
