/* Page shell: sidebar (desktop) / bottom bar (mobile), header, main, backdrop.
   The 860px breakpoint is pure CSS media queries — no JS needed to switch. */

body {
  display: flex;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

/* ── Sidebar (desktop, >=860px) ── */

.sidebar {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  width: 228px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 4px;
  box-sizing: border-box;
  transition: width .28s cubic-bezier(.4, 0, .2, 1), background .8s ease;
}

.sidebar[data-collapsed="true"] {
  width: 68px;
}

.sidebar[data-collapsed="true"] .sidebar-label {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px 6px;
  color: inherit;
  text-decoration: none;
  border-radius: 9px;
}
.sidebar-brand:hover .sidebar-wordmark { color: var(--primary); }

.sidebar-logo {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-wordmark {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.2px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  min-height: var(--tap);
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--t-md);
  font-weight: 400;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  text-decoration: none;
  box-sizing: border-box;
  transition: background .18s ease;
}

.nav-item:hover { background: var(--surface2); }

.nav-item[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--good-ink);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}
.nav-item[aria-current="page"]:hover { background: var(--primary-soft); }

.nav-item-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: flex;
}

.sidebar-spacer { margin-top: auto; }

.nav-account {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.nav-account-info {
  cursor: default;
  color: var(--ink);
  font-weight: 500;
}
.nav-account-info:hover { background: transparent; }

.sidebar-toggle {
  color: var(--faint);
}
.sidebar-toggle:hover { background: var(--surface2); color: var(--ink); }

/* ── Main column ── */

.main {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}
.main.scroll-locked {
  overflow-y: hidden;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 22px var(--pad) 14px var(--pad);
}

.header-left { min-width: 0; }

.header-loc {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: var(--t-sm);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.header-place {
  margin: 6px 0 0 0;
  font-family: 'Archivo', sans-serif;
  font-size: var(--t-h1);
  font-weight: 700;
  letter-spacing: -.7px;
  line-height: 1.1;
}

/* ── Header location switcher (logged-in users only) ── */

.header-loc-wrap { position: relative; }

.header-loc-trigger {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: none;
  background: none;
  padding: 4px 8px;
  margin: -4px -8px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
}
.header-loc-trigger:hover,
.header-loc-trigger:focus-visible { background: var(--surface2); }
.header-loc-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.header-loc-trigger-text { display: block; min-width: 0; }

.header-loc-chevron {
  display: flex;
  flex: 0 0 auto;
  color: var(--faint);
  margin-bottom: 9px;
  transition: transform .15s ease;
}
.header-loc-trigger[aria-expanded="true"] .header-loc-chevron { transform: rotate(180deg); }

.header-loc-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 40;
}
.header-loc-menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: none;
  font: inherit;
  font-size: var(--t-base);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  padding: 10px 12px;
  min-height: var(--tap);
  border-radius: 9px;
  cursor: pointer;
}
.header-loc-menu-item:hover { background: var(--surface2); }
.header-loc-menu-item.is-active { color: var(--good-ink); background: var(--primary-soft); font-weight: 600; }
.header-loc-menu-item.is-manage { color: var(--primary); font-size: var(--t-sm); }
.header-loc-menu-list { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 4px 0; padding: 4px 0; }
.header-loc-menu-empty { padding: 10px 12px; font-size: var(--t-sm); color: var(--faint); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.phase-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  min-height: var(--tap);
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.phase-pill-icon { display: flex; color: var(--sun); }
.phase-pill-text { line-height: 1.25; }
.phase-clock { font-family: 'IBM Plex Mono', monospace; font-size: var(--t-base); font-weight: 500; }
.phase-label { font-size: var(--t-xs); color: var(--muted); }

/* ── Bottom nav (mobile, <860px) ── */

.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)) 4px;
  box-shadow: 0 -4px 20px rgba(11, 34, 57, .08);
}

.bottom-nav-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
  padding: 6px 2px;
  color: var(--muted);
  font-family: inherit;
  text-decoration: none;
}

.bottom-nav-item[aria-current="page"] {
  color: var(--good-ink);
  box-shadow: inset 0 2px 0 var(--primary);
}

.bottom-nav-label { font-size: 11px; font-weight: 500; }

@media (max-width: 859px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .main { padding-bottom: 84px; }
}

/* ── Bell + avatar menu (logged in, includes/header.php) ── */
.header-social { display: flex; align-items: center; gap: 6px; }
.header-pop-wrap { position: relative; }
.header-icon-button,
.header-avatar-button {
  position: relative;
  display: grid;
  place-items: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.header-avatar-button { border: none; background: none; box-shadow: none; }
.header-icon-button:hover { color: var(--ink); }
.header-icon-button:focus-visible,
.header-avatar-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.bell-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--rough-ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.bell-badge[hidden] { display: none; }
.header-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  min-width: 220px;
  max-width: min(340px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 40;
}
#bell-menu { width: 340px; }
.header-pop-title {
  padding: 8px 12px 6px;
  font-family: 'Archivo', sans-serif;
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}
.bell-list { max-height: min(60vh, 420px); overflow-y: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 2px 0 4px; padding: 4px 0; }
.bell-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: var(--t-md);
  line-height: 1.4;
}
.bell-item:hover { background: var(--surface2); }
.bell-item.is-unread { background: var(--primary-soft); }
.bell-item-text { min-width: 0; }
.bell-item-time { display: block; font-size: var(--t-xs); color: var(--faint); margin-top: 2px; }
.bell-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 12px; color: var(--muted); font-size: var(--t-md); text-align: center; }
.bell-empty span { font-size: 26px; }

@media (max-width: 859px) {
  /* Bell + avatar sit in the top-right corner on phones, so they never
     push the clock/Bedste dage chip onto an extra line. */
  .app-header { position: relative; }
  body[data-logged-in] .header-left { padding-right: 150px; }
  .header-social { position: absolute; top: 16px; right: var(--pad); }
  .header-pop { position: fixed; top: 64px; left: 16px; right: 16px; width: auto; max-width: none; }
  #bell-menu { width: auto; }
}

/* Beta button (logged in, next to the bell — core/beta.js) */
.header-beta-button {
  min-height: 30px;
  padding: 0 11px;
  border: 1px dashed var(--sun);
  border-radius: 999px;
  background: var(--cau-bg);
  color: var(--cau-ink);
  font: inherit;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}
.header-beta-button:hover { border-style: solid; }
.header-beta-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
