/* Chucktown Solutions — shared styles. Mobile first; desktop tweaks at the bottom. */
:root {
  --ink: #0b1220;
  --ink-2: #111a2c;
  --glass: rgba(11, 18, 32, 0.62);
  --glass-strong: rgba(11, 18, 32, 0.86);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f1f5f9;
  --muted: #a8b3c4;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --accent-ink: #04202e;
  --sand: #f4e9d8;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--text); background: var(--ink); min-height: 100vh; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: 1.15rem; }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- Backgrounds (kept from the original site) ---- */
.bg-beach1 { background-image: url("../images/beach1-sm.jpg"); }
.bg-beach2 { background-image: url("../images/beach2-sm.jpg"); }
.bg-beach4 { background-image: url("../images/beach4-sm.jpg"); }
.bg-beach5 { background-image: url("../images/beach5-sm.jpg"); }
.bg-hero::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background: url("../images/hero-beach-sm.jpg") center 60% / cover no-repeat;
}
.bg-hero::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(11,18,32,.55) 0%, rgba(11,18,32,.15) 35%, rgba(11,18,32,.35) 100%);
}
.editor-page::after, body.app:not(.dashboard):not(.centered)::after {
  background: linear-gradient(180deg, rgba(11,18,32,.75), rgba(11,18,32,.88));
}

/* ---- Building blocks ---- */
.glass { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { background: var(--glass-strong); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.brand { font-weight: 800; letter-spacing: -.01em; color: var(--text); text-decoration: none; font-size: 1.15rem; white-space: nowrap; }
.brand span { color: var(--accent); }
.brand-lg { font-size: 1.6rem; display: block; margin-bottom: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font: 600 .95rem var(--font);
  text-decoration: none; cursor: pointer; transition: background .15s, transform .05s;
}
.btn:hover { background: #7dd3fc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248,113,113,.5); }
.btn-danger:hover { background: rgba(248,113,113,.12); }
.linklike { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; text-align: left; width: 100%; }

input, select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text);
  font: 16px var(--font); /* 16px stops iOS zooming into inputs */
}
input:focus, select:focus, summary:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
select option { background: var(--ink-2); }
label { display: block; font-size: .875rem; color: var(--muted); }
label > input, label > select { margin-top: 6px; color: var(--text); }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); }
.stack > * + * { margin-top: 14px; }

.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; border: 1px solid; }
.flash-ok { background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.4); }
.flash-error { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.45); }

.tag { display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); vertical-align: 2px; }
.tag-admin { color: var(--accent); border-color: rgba(56,189,248,.5); }
.tag-you { color: var(--ok); border-color: rgba(74,222,128,.45); }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; flex: none; }

/* ---- Public home ---- */
.hero {
  min-height: 100svh; display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px 16px 40px; background-position: center 60%; background-size: cover; position: relative;
}
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,18,32,.5), rgba(11,18,32,0) 30%, rgba(11,18,32,.45)); }
.hero > * { position: relative; }
.public-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.public-links { display: flex; align-items: center; gap: 14px; }
.public-links a:not(.btn) { color: var(--text); text-decoration: none; font-weight: 500; display: none; }
.hero-copy { padding: 22px; max-width: 640px; margin-top: auto; }
.hero-copy h1 { text-transform: uppercase; letter-spacing: .02em; }
.hero-copy p { color: #dbe4ef; margin: 0 0 18px; }
.eyebrow { color: var(--accent) !important; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; margin: 0 0 6px !important; }

.section { padding: 48px 16px; max-width: 1180px; margin: 0 auto; }
.section-title { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.section-sub { color: var(--muted); margin-top: -4px; }
.cards { display: grid; gap: 16px; }
.card {
  border-radius: var(--radius); overflow: hidden; background-size: cover; background-position: center;
  min-height: 300px; display: flex; align-items: flex-end; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card-body { background: linear-gradient(180deg, rgba(11,18,32,0), rgba(11,18,32,.82) 28%, rgba(11,18,32,.94)); padding: 64px 18px 18px; width: 100%; }
.card-body p { color: #cfd9e6; font-size: .95rem; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.gallery a { display: block; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.gallery a:hover img { transform: scale(1.04); }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 28px 16px 40px; border-top: 1px solid var(--line); }

.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.lightbox::backdrop { background: rgba(0,0,0,.9); }
.lightbox img { max-width: 100%; max-height: 100%; margin: auto; position: absolute; inset: 0; object-fit: contain; }
.lb-close, .lb-nav { position: absolute; z-index: 2; background: rgba(0,0,0,.5); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 28px; cursor: pointer; }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 8px; top: 50%; }
.lb-next { right: 8px; top: 50%; }

/* ---- Auth ---- */
body.centered { display: grid; place-items: center; padding: 16px; }
.auth { width: 100%; max-width: 380px; padding: 28px 22px; text-align: center; }
.auth form { text-align: left; margin: 18px 0; }

/* ---- Signed-in shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(11,18,32,.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.account summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; padding: 4px; border-radius: 99px; }
.account summary::-webkit-details-marker { display: none; }
.account .who { display: none; }
.page { padding: 20px 16px 120px; max-width: 900px; margin: 0 auto; }
.page.narrow { max-width: 480px; }
.page.wide { max-width: 1280px; }

/* ---- Dropdowns (<details>) ---- */
.dd { position: relative; }
.dd > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 48px; padding: 0 16px; font-weight: 600;
}
.dd > summary::-webkit-details-marker { display: none; }
.menus .dd > summary::after, .sub > summary::after { content: "▾"; font-size: .8em; color: var(--muted); transition: transform .15s; }
.dd[open] > summary::after, .sub[open] > summary::after { transform: rotate(180deg); }
.dd-panel { display: flex; flex-direction: column; padding: 6px; }
.dd-panel a, .dd-panel .linklike, .sub > summary {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.dd-panel a:hover, .dd-panel .linklike:hover, .sub > summary:hover, .dd-panel a:focus-visible { background: rgba(56,189,248,.14); }
.dd-panel a[aria-current] { color: var(--accent); }
.sub > summary { list-style: none; cursor: pointer; justify-content: space-between; font-weight: 600; }
.sub > summary::-webkit-details-marker { display: none; }
.sub-panel { display: flex; flex-direction: column; margin-left: 10px; padding-left: 8px; border-left: 2px solid rgba(56,189,248,.35); }
.account .dd-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.account .dd-panel form { margin: 0; }

/* ---- Dashboard ---- */
.dash { padding: 14px 16px 60px; max-width: 1200px; margin: 0 auto; }
.dash-tools { display: flex; gap: 10px; margin-bottom: 12px; }
.search { flex: 1; }
.search input { background: var(--glass-strong); }
.menus { display: flex; flex-direction: column; gap: 8px; }
.menu-row { display: flex; flex-direction: column; gap: 8px; }
.menus .dd { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; }
.menus .dd-panel { border-top: 1px solid var(--line); }
.search-results { padding: 6px; display: flex; flex-direction: column; margin-top: 8px; }
.search-results a { display: flex; justify-content: space-between; gap: 10px; min-height: 44px; align-items: center; padding: 0 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.search-results a:hover, .search-results a:focus-visible { background: rgba(56,189,248,.14); }
.search-results .where { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.empty { padding: 24px; text-align: center; }

/* ---- Users ---- */
.user-list { list-style: none; margin: 0; padding: 0; }
.user { border-top: 1px solid var(--line); padding: 14px 0; }
.user:first-child { border-top: 0; padding-top: 0; }
.user-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.push { margin-left: auto; }
.user-more > summary { cursor: pointer; color: var(--muted); font-size: .875rem; margin-top: 8px; min-height: 32px; display: inline-flex; align-items: center; }
.user-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { flex: 1 1 160px; width: auto; min-height: 36px; }
.grid-form { display: grid; gap: 14px; }

/* ---- Menu editor ---- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.head-actions select { min-height: 36px; padding: 4px 8px; }
.file-btn { color: var(--text); }
.handle-demo { color: var(--accent); }
.rows { display: grid; gap: 18px; }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.row-head h2 { margin: 0; }
.menu-list { display: flex; flex-direction: column; gap: 12px; min-height: 60px; border-radius: 10px; }
.menu-list:empty::before { content: "No menus in this row yet — tap “+ Menu” or drag one here."; color: var(--muted); font-size: .875rem; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; }
.menu-card { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.menu-card.collapsed .items, .menu-card.collapsed > .add-row { display: none; }
.menu-card.collapsed .collapse { transform: rotate(-90deg); }
.node-row { display: flex; align-items: center; gap: 8px; }
.menu-name { font-weight: 700; }
.node-row .label-in { flex: 1; min-width: 0; }
.label-in, .url-in { min-height: 38px; padding: 6px 10px; }
.items { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 0 10px; min-height: 12px; padding-bottom: 4px; }
.sub-items { margin-left: 22px; border-left: 2px solid rgba(56,189,248,.35); padding-left: 8px; }
.node { background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 6px; }
.link-node { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "h f x" "h n x"; gap: 6px 8px; align-items: center; }
.link-node .handle { grid-area: h; }
.link-node .link-fields { grid-area: f; display: grid; gap: 6px; }
.link-node .newtab { grid-area: n; display: flex; align-items: center; gap: 6px; }
.link-node .icon-btn { grid-area: x; }
.sub-node { background: rgba(56,189,248,.05); border-color: rgba(56,189,248,.25); }
.sub-icon { color: var(--accent); }
.add-row { display: flex; gap: 8px; margin-top: 8px; margin-left: 10px; }
.handle { cursor: grab; color: var(--muted); font-size: 20px; padding: 6px 4px; touch-action: none; user-select: none; }
.handle:hover { color: var(--accent); }
.collapse, .icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; min-width: 36px; min-height: 36px; border-radius: 8px; transition: transform .15s; }
.icon-btn.danger:hover { color: var(--danger); background: rgba(248,113,113,.12); }
.count { white-space: nowrap; }
.invalid { border-color: var(--danger) !important; background: rgba(248,113,113,.08) !important; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 0 0 2px var(--accent); }
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--glass-strong); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.save-status { margin-right: auto; color: var(--muted); font-size: .875rem; }
.save-status.dirty { color: #fbbf24; }
.save-status.error { color: var(--danger); }
.save-status.saved { color: var(--ok); }

/* ---- Tablet / desktop ---- */
@media (min-width: 700px) {
  .bg-beach1 { background-image: url("../images/beach1.jpg"); }
  .bg-hero::before { background-image: url("../images/hero-beach.jpg"); }
  .public-links a:not(.btn) { display: inline; }
  .hero { padding: 22px 40px 64px; }
  .hero-copy { padding: 32px; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .gallery { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .account .who { display: inline; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .span-2 { grid-column: span 2; }
  .link-node { grid-template-columns: auto 1fr 1.6fr auto auto; grid-template-areas: "h f f n x"; }
  .link-node .link-fields { grid-template-columns: 1fr 1.6fr; }
}

/* Desktop dashboard: menus become two centered rows of floating dropdowns. */
@media (min-width: 900px) {
  .dash-tools { justify-content: center; }
  .search { flex: 0 1 420px; }
  .menus { align-items: center; gap: 10px; }
  .menu-row { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .menus .dd { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 99px; }
  .menu-row-2 .dd { font-size: .92rem; }
  .menus .dd > summary { min-height: 42px; padding: 0 18px; }
  /* backdrop-filter makes each pill its own stacking context, so lift the open one above row 2. */
  .menus .dd[open] { border-color: rgba(56,189,248,.6); z-index: 25; }
  .menus .dd-panel {
    position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 8px); z-index: 20;
    min-width: 240px; max-height: 70vh; overflow-y: auto;
    background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  }
  .menus .dd-panel a { white-space: nowrap; }
  .rows { grid-template-columns: 1fr 1fr; align-items: start; }
}

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