/**
 * Menu page — grouped settings list on warm paper.
 *
 * One ground (paper), cream groups, one accent (amber-deep). The colour sits
 * in the icon tiles, one hue per group, so the eye can find a section
 * without reading. Everything is scoped under .menu-body / .menu-page:
 * `:app` bundles this file into every default-layout page.
 */

html:has(.menu-body) {
  background: var(--paper);
}

.menu-body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  background-image: var(--grain);
  background-size: 4px 4px;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.menu-page,
.menu-page *,
.menu-page *::before,
.menu-page *::after {
  box-sizing: border-box;
}

.menu-page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 28px);
}

.menu-page .hidden,
.menu-page [hidden] {
  display: none !important;
}

/* ---------- Top bar ---------- */
.menu-top {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

.menu-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  background: var(--paper-card);
  border: 1px solid var(--ink-line);
  box-shadow: var(--shadow-warm);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.menu-back:hover {
  background: var(--surface-hover);
}

/* ---------- Updates available ---------- */
.menu-updates {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 14px;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--sage-deep);
  color: #ffffff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-warm);
}

.menu-updates:hover {
  background: #45502f;
}

.menu-updates:disabled {
  opacity: 0.7;
  cursor: default;
}

.menu-updates svg {
  flex-shrink: 0;
}

.menu-updates__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-updates__title {
  font-size: 16px;
  font-weight: 700;
}

.menu-updates__desc {
  font-size: 13px;
  opacity: 0.85;
}

/* ---------- Who is walking ---------- */
.menu-you {
  background: var(--paper-card);
  border: 1px solid var(--ink-line);
  border-radius: 14px;
  box-shadow: var(--shadow-warm);
  overflow: hidden;
}

.menu-you__card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 18px 18px 16px;
  color: inherit;
  text-decoration: none;
}

.menu-you[data-anonymous] .menu-you__card {
  pointer-events: none;
}

.menu-you:not([data-anonymous]) .menu-you__card:hover {
  background: var(--surface-hover);
}

.menu-you__logo {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.menu-you__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.menu-you__eyeline {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.menu-you__line {
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink-soft);
}

.menu-you__chevron {
  color: var(--ink-soft);
  flex-shrink: 0;
  display: flex;
}

.menu-you__reclaim {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  border-top: 1px solid var(--ink-line);
  color: var(--amber-deep);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
}

.menu-you__reclaim:hover {
  background: var(--surface-hover);
}

/* ---------- Sections ---------- */
.menu-heading {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 26px 6px 10px;
}

.menu-group {
  background: var(--paper-card);
  border: 1px solid var(--ink-line);
  border-radius: 14px;
  box-shadow: var(--shadow-warm);
  overflow: hidden;
}

/* ---------- Rows ---------- */
.menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px 12px 14px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--ink-line);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-row:first-child {
  border-top: 0;
}

.menu-row:hover {
  background: var(--surface-hover);
}

.menu-row--control {
  cursor: default;
}

.menu-row--control:hover {
  background: transparent;
}

.menu-row__icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.menu-row__icon svg {
  display: block;
}

.menu-row__icon--trail {
  background: var(--sage-bg);
  color: var(--sage-deep);
}

.menu-row__icon--leaf {
  background: #e3ecd6;
}

.menu-row__icon--help {
  background: #fbeae1;
  color: var(--terra);
}

.menu-row__icon--about {
  background: var(--surface-sunken);
  color: var(--amber-deep);
}

.menu-row__icon--coffee {
  background: var(--amber-deep);
  color: #ffffff;
}

.menu-row__icon--app {
  background: var(--surface-sunken);
  color: var(--ink-soft);
}

.menu-row__img {
  width: 32px;
  height: 32px;
  display: block;
}

.menu-row__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.menu-row__label {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
}

.menu-row__sub {
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--ink-soft);
}

.menu-row__chevron {
  display: flex;
  flex-shrink: 0;
  color: var(--ink-soft);
}

/* Controls on the right of a row */
.menu-select {
  flex-shrink: 0;
  max-width: 46%;
  min-height: 44px;
  padding: 0 36px 0 14px;
  border: 1.5px solid var(--ink-line);
  border-radius: 8px;
  background: var(--paper-card)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232d2114' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>")
    no-repeat right 12px center / 16px;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  cursor: pointer;
}

.menu-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--amber-deep);
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.menu-btn:hover {
  background: #7f3b0e;
}

/* Keyboard focus */
.menu-page a:focus-visible,
.menu-page button:focus-visible,
.menu-page select:focus-visible {
  outline: 3px solid var(--amber-deep);
  outline-offset: -3px;
}

/* ---------- Offline tiles: download in progress ---------- */
.prefetch-tile__default {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.prefetch-tile__progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
}

.prefetch-tile__info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.prefetch-tile__label {
  font-size: 15px;
  font-weight: 600;
}

.prefetch-tile__stats {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.prefetch-tile__bar-track {
  width: 100%;
  height: 8px;
  background: var(--surface-sunken);
  border-radius: 4px;
  overflow: hidden;
}

.prefetch-tile__bar-fill {
  height: 100%;
  width: 0;
  background: var(--amber-deep);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.prefetch-tile__cancel {
  align-self: flex-end;
  min-height: 40px;
  padding: 0 16px;
  border: 1.5px solid var(--ink-line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.prefetch-tile__cancel:hover {
  background: var(--surface-hover);
}

/* ---------- App update waiting ---------- */
.menu-row.has-app-update .menu-row__icon {
  background: var(--amber-deep);
  color: #ffffff;
}

.menu-row.has-app-update .menu-row__sub {
  color: var(--amber-deep);
  font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes menu-pulse {
    0%,
    100% {
      box-shadow: 0 0 0 0 rgba(156, 74, 19, 0.5);
    }
    50% {
      box-shadow: 0 0 0 8px rgba(156, 74, 19, 0);
    }
  }

  .menu-row.has-app-update .menu-row__icon {
    animation: menu-pulse 2s ease-in-out infinite;
  }
}

/* ---------- Footer ---------- */
.menu-footer {
  margin-top: 26px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.menu-footer p {
  margin: 0;
}

.menu-footer a {
  color: var(--amber-deep);
  font-weight: 600;
  text-decoration: none;
}

.menu-footer a:hover {
  text-decoration: underline;
}

/* ---------- Desktop ---------- */
@media (min-width: 720px) {
  .menu-page {
    padding-top: 28px;
  }

  .menu-heading {
    font-size: 23px;
  }
}
