/* ============================================================
   MEMBER DRAWER — Dashboard
   Editorial warm-light panel. Orange header, cream body.
   WIRED magazine department-slug treatment.
   ============================================================ */

/* ── Design tokens ── */

.md-overlay,
.md-panel {
  /* Body — very light orange wash over white */
  --md-bg:         rgb(255 255 255);        /* solid white base under transparent wash */
  --md-body-wash:  rgb(0 0 0 / 0.05);
  --md-surface:    oklch(0.93 0.012 50);
  --md-rule:       oklch(0.88 0.012 50);
  --md-rule-mid:   oklch(0.80 0.016 50);
  /* Text tokens */
  --md-text:       oklch(0.18 0.012 48);
  --md-text-mid:   oklch(0.37 0.012 50);
  --md-text-muted: oklch(0.55 0.010 62);
  /* Mauve — reserved now for the Premium (Saved Comparisons) section */
  --md-mauve:      oklch(0.47 0.22 310);
  --md-on-mauve:   oklch(0.97 0.006 310);
  /* Pistachio — the free Member dashboard identity (brand green, dark text) */
  --md-green:      rgb(161, 184, 57);
  --md-on-green:   var(--md-text);
  /* Orange — kept for other accent uses */
  --md-orange:     oklch(0.52 0.19 38);
  --md-on-orange:  oklch(0.97 0.006 58);
  /* Fonts */
  --md-font:       'Exo 2', sans-serif;
  --md-body-font:  'Figtree', sans-serif;
}

/* ── OVERLAY ──
   Warm tinted veil — not cold neutral black.
   45% opacity keeps the site's grain texture visible. */

.md-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0.22 0.04 50 / 0.45);
  z-index: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.md-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── PANEL ── */

.md-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 316px;
  z-index: 900;
  transform: translateX(-100%);
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
}

.md-panel.is-open {
  transform: translateX(0);
}

/* ── TOGGLE TAB ──
   The entire tab is orange — the only orange sliver at the left edge.
   An unmissable magazine page-flag. */

/* ── TOGGLE TAB — mauve split-zone, vertical orientation ── */

.md-toggle {
  --_mauve:       rgb(161, 184, 57);           /* pistachio — the Member green */
  --_icon-zone:   color-mix(in oklch, var(--_mauve), black 20%);
  --_hover-bg:    color-mix(in oklch, var(--_mauve), white 10%);

  position: absolute;
  right: -38px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 150px;
  background: var(--_mauve);
  border-right: 1px solid color-mix(in oklch, var(--_mauve), black 30%);
  border-bottom: 1px solid color-mix(in oklch, var(--_mauve), black 30%);
  border-top: 1px solid color-mix(in oklch, var(--_mauve), black 30%);
  color: var(--md-text);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: background 0.28s cubic-bezier(0.25, 1, 0.5, 1);
}

.md-toggle:hover {
  background: var(--_hover-bg);
}

.md-toggle:active {
  background: color-mix(in oklch, var(--_mauve), black 12%);
}

.md-toggle:focus-visible {
  outline: 2px solid oklch(0.18 0.012 48);
  outline-offset: 2px;
}

/* Icon zone — darker top band */
.md-toggle-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0.7rem 0 0.25rem;
  /* one clean tone — no darker icon band */
}

/* Chevron */
.md-toggle-icon {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
}

.md-panel.is-open .md-toggle-icon {
  transform: rotate(180deg);
}

/* Vertical label — fills remaining height, centres text */
.md-toggle-label {
  flex: 1;
  display: grid;
  align-items: center;
  justify-items: center;
  font-family: var(--md-font);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  line-height: 1;
  padding: 0.9rem 0;
}

.md-label-default,
.md-label-open {
  /* Both spans in the same grid cell = stacked without absolute positioning */
  grid-area: 1 / 1;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.md-label-default {
  opacity: 1;
}

.md-label-open {
  opacity: 0;
}

.md-panel.is-open .md-label-default {
  opacity: 0;
}

.md-panel.is-open .md-label-open {
  opacity: 1;
}

/* ── INNER PANEL ── */

.md-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--md-bg);
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: auto;
}

.md-panel.is-open .md-inner {
  box-shadow: 4px 0 32px oklch(0.14 0.02 50 / 0.18);
}

/* ── PANEL HEADER — mauve masthead ── */

.md-head {
  flex-shrink: 0;
}

.md-head-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1.25rem 1.1rem 1.1rem 1.5rem;
  background: var(--md-green);
}

/* "MEMBER" eyebrow — dark olive on pistachio */
.md-head-eyebrow {
  display: block;
  font-family: var(--md-font);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: color-mix(in oklch, var(--md-green), black 55%);
  margin-bottom: 0.35rem;
  line-height: 1;
}

.md-head-title {
  font-family: var(--md-font);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--md-on-green);
  line-height: 1;
  display: block;
}

/* × button — dark on pistachio header */
.md-head-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: color-mix(in oklch, var(--md-green), black 42%);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s;
}

.md-head-close:hover {
  color: var(--md-on-green);
}

.md-head-close:focus-visible {
  outline: 1px solid var(--md-on-green);
  outline-offset: 2px;
}

.md-head-close svg {
  width: 13px;
  height: 13px;
}

/* ── PANEL BODY ── */

.md-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--md-rule-mid) transparent;
  padding-bottom: 3rem;
  background: var(--md-body-wash);
}

/* ── LOADING STATE ── */

@keyframes md-pulse {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 0.25; }
}

.md-loading {
  padding: 2.5rem 1.5rem;
  color: var(--md-text-muted);
  font-family: var(--md-font);
  font-size: 0.875rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.md-loading span {
  display: inline-block;
  animation: md-pulse 1.6s ease-in-out infinite;
}

/* ── EMPTY STATE — Figtree for body prose ── */

.md-empty {
  padding: 0.4rem 1.5rem 1.75rem;
  color: var(--md-text-muted);
  font-family: var(--md-body-font);
  font-size: 0.875rem;
  line-height: 1.75;
  font-weight: 400;
}

/* ── SECTION ── */

.md-section {
  padding-top: 2rem;
}

.md-section + .md-section {
  margin-top: 0.5rem;
  padding-top: 1.75rem;
}

/* Content reveal — staggered fade-in after data loads */
@keyframes md-reveal {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.md-body--loaded .md-section {
  animation: md-reveal 0.38s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.md-body--loaded .md-section:nth-child(2) {
  animation-delay: 0.08s;
}

/* Section header: [01]  FAVOURITES */
.md-section-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0 1.5rem 0.85rem;
}

/* "01" / "02" — orange numeral on cream.
   The colour contrast is more vivid here than it was on dark. */
.md-section-num {
  font-family: var(--md-font);
  font-size: 0.875rem;
  font-weight: 900;
  letter-spacing: 0;
  color: var(--md-orange);
  line-height: 1;
  flex-shrink: 0;
}

.md-section-label {
  font-family: var(--md-font);
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--md-text);
  line-height: 1;
}

/* ── GROUP LABEL ── */

.md-group-label {
  display: block;
  font-family: var(--md-font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--md-text-muted);
  padding: 0.85rem 1.5rem 0.3rem;
}

/* ── ITEM ROW ── */

.md-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.58rem 1rem 0.58rem 1.5rem;
  position: relative;
  transition: background 0.12s;
}

.md-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 1.5rem;
  right: 1rem;
  height: 1px;
  background: var(--md-rule);
  transition: background 0.12s;
}

.md-item:hover {
  /* Neutral light grey — no warmth */
  background: oklch(0.94 0 0);
}

.md-item:hover::after {
  background: var(--md-rule-mid);
}

.md-item-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
}

.md-item-link:focus-visible {
  outline: none;
}

.md-item-link:focus-visible .md-item-name {
  color: var(--md-orange);
}

.md-item-name {
  display: block;
  font-family: var(--md-body-font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--md-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  transition: color 0.12s;
}

a.md-item-link:hover .md-item-name {
  color: var(--md-orange);
}

/* Tool tag — reads as one of our tools, in the Premium mauve */
.md-item-sub {
  display: inline-block;
  font-family: var(--md-font);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-mauve);
  background: color-mix(in oklch, var(--md-mauve), white 84%);
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  margin-top: 0.35rem;
  white-space: nowrap;
}

/* ── OPEN LINK — "OPEN →" editorial text link ── */

.md-item-load {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  color: var(--md-text-mid);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--md-body-font);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.15s;
}

.md-item-load:hover {
  color: var(--md-mauve);
}

.md-item-load:focus-visible {
  outline: 1px solid var(--md-orange);
  outline-offset: 2px;
}

/* ── DELETE / UNFOLLOW — ghosts in on hover ── */

.md-item-del {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  color: var(--md-text-muted);
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: color 0.15s, opacity 0.15s;
}

.md-item:hover .md-item-del,
.md-item-del:focus-visible {
  opacity: 1;
}

.md-item-del:hover {
  color: var(--md-orange);
}

.md-item-del:focus-visible {
  outline: 1px solid var(--md-orange);
  outline-offset: 2px;
}

.md-item-del svg {
  width: 9px;
  height: 9px;
}

/* ── RENAME — pencil button, same ghost treatment as delete ── */

.md-item-rename {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  color: var(--md-text-muted);
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: color 0.15s, opacity 0.15s;
}

.md-item:hover .md-item-rename,
.md-item-rename:focus-visible {
  opacity: 1;
}

.md-item-rename:hover {
  color: var(--md-orange);
}

.md-item-rename:focus-visible {
  outline: 1px solid var(--md-orange);
  outline-offset: 2px;
}

.md-item-rename svg {
  width: 9px;
  height: 9px;
}

/* ── RENAME INPUT — inline edit, blends into the item row ── */

.md-item-rename-input {
  flex: 1;
  min-width: 0;
  font-family: var(--md-font);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--md-text);
  background: var(--md-surface);
  border: 1px solid var(--md-rule-mid);
  border-radius: 0;
  padding: 0.15rem 0.35rem;
  line-height: 1.2;
  outline: none;
  /* Snap into focus with an orange underline — no radius, no card box */
  box-shadow: none;
  transition: border-color 0.15s;
}

.md-item-rename-input:focus {
  border-color: var(--md-orange);
}

/* ── SCROLL LOCK ── */

body.md-open {
  overflow: hidden;
}

/* ── RESPONSIVE ── */

@media (max-width: 700px) {
  .md-panel {
    width: 88vw;
  }

  /* Keep the full-height tab so the vertical "Dashboard" label still reads */
  .md-toggle {
    width: 38px;
    right: -38px;
  }
}

/* ── REDUCED MOTION ── */

@media (prefers-reduced-motion: reduce) {
  .md-overlay,
  .md-panel,
  .md-toggle,
  .md-toggle-icon,
  .md-label-default,
  .md-label-open,
  .md-head-close,
  .md-item,
  .md-item::after,
  .md-item-name,
  .md-item-load,
  .md-item-del,
  .md-item-rename,
  .md-item-rename-input {
    transition: none !important;
  }

  .md-loading span {
    animation: none;
    opacity: 0.5;
  }

  .md-body--loaded .md-section {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* Freemium tier: follow counter, at-limit nudge, locked comparisons */
.md-count {
  margin-left: auto;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-light);
}
.md-upsell {
  display: block;
  margin-top: 0.85rem;
  font-family: 'Figtree', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--orange);
  text-decoration: none;
}
.md-upsell:hover { text-decoration: underline; }
.md-locked a { color: var(--orange); text-decoration: none; font-weight: 700; }
.md-locked a:hover { text-decoration: underline; }

/* Premium tag on the Saved Comparisons section — mauve = Premium */
.md-prem-tag {
  margin-left: auto;
  align-self: center;
  font-family: var(--md-font);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--md-mauve);
  border: 1px solid color-mix(in oklch, var(--md-mauve), white 55%);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}

/* Return-engine meta — a followed item's season headline (neutral, calm) */
.md-item-meta {
  flex-shrink: 0;
  font-family: var(--md-font);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--md-text-mid);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Footer link to the (separate) Account & settings page. */
.md-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--md-rule);
  background: var(--md-bg);
  text-decoration: none;
  font-family: 'Exo 2', sans-serif; font-weight: 700; font-size: 0.9rem;
  color: var(--md-text);
  transition: color 0.15s ease;
}
.md-foot-arrow { color: var(--orange); transition: transform 0.15s ease; }
.md-foot:hover { color: var(--orange); }
.md-foot:hover .md-foot-arrow { transform: translateX(3px); }

/* Guest "start here" state — inline passwordless signup inside the drawer. */
.md-guest { padding: 1.5rem 1.25rem; }
.md-guest-lead {
  margin: 0 0 0.5rem; font-family: 'Exo 2', sans-serif; font-weight: 800;
  font-size: 1.15rem; line-height: 1.15; letter-spacing: -0.01em; color: var(--md-text);
}
.md-guest-desc {
  margin: 0 0 1.1rem; font: 400 0.88rem/1.5 'Figtree', sans-serif;
  color: color-mix(in oklch, var(--md-text), transparent 25%);
}
.md-guest-form { display: flex; flex-direction: column; gap: 0.6rem; }
.md-guest-input {
  width: 100%; box-sizing: border-box;
  font: 400 0.95rem/1 'Figtree', sans-serif; color: var(--md-text);
  background: #fff; border: 1px solid var(--md-rule-mid); border-radius: 4px;
  padding: 0.75rem 0.85rem;
}
.md-guest-input:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; border-color: var(--orange); }
.md-guest-btn {
  width: 100%; border: 0; cursor: pointer; border-radius: 4px;
  background: var(--orange); color: #fff; font-weight: 700;
  font-family: 'Figtree', sans-serif; font-size: 0.95rem; padding: 0.8rem 1rem;
  transition: background 0.15s ease;
}
.md-guest-btn:hover { background: color-mix(in oklch, var(--orange), black 12%); }
.md-guest-check {
  display: flex; align-items: center; gap: 0.45rem; cursor: pointer;
  font: 400 0.8rem/1.3 'Figtree', sans-serif;
  color: color-mix(in oklch, var(--md-text), transparent 25%);
}
.md-guest-check input { accent-color: var(--orange); }
.md-guest-note {
  margin: 1rem 0 0; font: 400 0.78rem/1.45 'Figtree', sans-serif;
  color: color-mix(in oklch, var(--md-text), transparent 40%);
}
.md-guest-note a { color: var(--orange); font-weight: 600; text-decoration: none; }
.md-guest-note a:hover { text-decoration: underline; }
