/* Kafedrum — profile page. Loaded after minimal.css; styles only #account-view (the profile as its own view of the app,
   public-config account_page_enabled). Uses the stage layer's tokens, so both themes follow it. Removing the <link> leaves
   an unstyled but working page; with the switch off the view is never shown.
   Phones first: one column, section chips stick under the top bar. From 851 px: a column of chips beside the sections. */

.account-view { --ap-gap: 16px; --ap-group-gap: 40px; padding-bottom: var(--space-7); }

.account-head { display: flex; align-items: center; gap: 16px; padding: 0 0 24px; }
.account-avatar { width: 56px; height: 56px; flex: none; display: grid; place-items: center; font: 700 24px/1 var(--display); }
.account-head-copy { min-width: 0; }
.account-head .editorial-title { font-size: clamp(28px, 6vw, 40px); }
.account-head .page-lede { margin-top: 4px; }
.account-head .editorial-title:focus-visible { outline: none; }
.account-load:empty { display: none; }

.account-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; align-items: start; }
.account-main { min-width: 0; display: grid; gap: var(--ap-group-gap); padding-top: 24px; }

/* Section chips: a sticky row on phones, scrollable when the words do not fit, with a fade where more is hidden. */
.account-nav {
  position: sticky; top: var(--topbar-h); z-index: 3; display: flex; gap: 8px; margin: 0 calc(var(--gutter) * -1); padding: 8px var(--gutter);
  overflow-x: auto; scrollbar-width: none; background: var(--bg);
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
}
.account-nav::-webkit-scrollbar { display: none; }
.account-nav a {
  flex: none; min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 999px; background: var(--panel-3);
  color: var(--text); font: 500 15px/1 var(--display); text-decoration: none; transition: background-color .15s var(--ease-out);
}
.account-nav a:hover { background: var(--line-2); }
.account-nav a[aria-current="location"] { background: var(--text); color: var(--bg); }
.account-nav a:last-child { margin-right: 32px; }

.account-block { scroll-margin-top: calc(var(--topbar-h) + 72px); display: grid; gap: var(--ap-gap); align-content: start; }
.account-block > h2 { margin: 0; font: 700 22px/1.2 var(--display); letter-spacing: -.02em; }
.account-block > h2:focus-visible { outline: none; }
.account-block h3 { margin: 0; font: 600 16px/1.3 var(--display); }
.ap-lead { margin: 0; color: var(--muted); }
.ap-result { margin: 0; min-height: 0; }
.ap-result:empty { display: none; }
.account-block .form-error:empty { display: none; }

/* Identity */
.ap-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 24px; margin: 0; }
.ap-rows dt { margin-top: 12px; color: var(--subtle); font: 500 13px/1.4 var(--display); }
.ap-rows dt:first-child { margin-top: 0; }
.ap-rows dd { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; font: 500 17px/1.4 var(--display); }
.ap-value { min-width: 0; overflow-wrap: anywhere; }
.ap-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--text); font: 500 14px/1.2 var(--display); text-decoration: underline; text-underline-offset: 3px; }
.ap-link:hover { text-decoration-thickness: 2px; }
.ap-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 12px 0 8px; border-radius: 999px; background: var(--panel-3); font: 500 13px/1 var(--display); white-space: nowrap; }
.ap-chip .ui-icon { width: 16px; height: 16px; }
.ap-chip.is-good { color: var(--good-ink); }
.ap-chip.is-warn { background: var(--warn-surface); color: var(--warn-ink); }
.ap-notice { display: grid; gap: 12px; padding: 16px; border-radius: var(--radius-md); background: var(--warn-surface); box-shadow: inset 0 0 0 1px var(--warn-line); }
.ap-notice[hidden] { display: none; }
.ap-notice p { margin: 0; }
.ap-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.ap-form { display: grid; gap: 16px; padding: 16px; border-radius: var(--radius-md); background: var(--panel-2); }
.ap-form[hidden] { display: none; }
.ap-notice .ap-form { padding: 0; background: transparent; }

/* Limits */
.ap-limits { display: grid; gap: 12px; }
.ap-limit-pair { display: grid; gap: 12px; }
.ap-limit { display: grid; gap: 8px; padding: 20px; border-radius: var(--radius-md); background: var(--panel-2); }
.ap-limit-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.ap-limit-left { margin: 0; color: var(--muted); font: 400 15px/1.3 var(--display); }
.ap-limit-left strong { color: var(--text); font: 700 32px/1.1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ap-limit progress { width: 100%; height: 8px; margin: 4px 0; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--line-2); color: var(--text); }
.ap-limit progress::-webkit-progress-bar { background: var(--line-2); border-radius: 999px; }
.ap-limit progress::-webkit-progress-value { background: var(--text); border-radius: 999px; transition: width .3s var(--ease-out); }
.ap-limit progress::-moz-progress-bar { background: var(--text); border-radius: 999px; }
.ap-limit.is-low progress::-webkit-progress-value { background: var(--warn); }
.ap-limit.is-low progress::-moz-progress-bar { background: var(--warn); }
.ap-limit.is-out progress::-webkit-progress-value { background: var(--bad); }
.ap-limit.is-out progress::-moz-progress-bar { background: var(--bad); }
.ap-limit-meta { margin: 0; color: var(--muted); font: 400 14px/1.45 var(--display); }
.ap-limit-note { margin: 0; color: var(--text); font: 400 14px/1.45 var(--display); }
.ap-limit.is-out { box-shadow: inset 0 0 0 1px var(--bad-line); background: var(--bad-surface); }
.ap-flag { display: inline-flex; align-items: center; gap: 6px; font: 600 13px/1.2 var(--display); color: var(--warn-ink); }
.ap-flag .ui-icon { width: 16px; height: 16px; }
.ap-limit.is-out .ap-flag { color: var(--bad-ink); }
.ap-fail { display: grid; justify-items: start; gap: 12px; }
.ap-fail .form-error { max-width: 60ch; }

/* Plans */
.ap-plans { display: grid; gap: 12px; }
.ap-plan { display: grid; align-content: start; gap: 8px; padding: 20px; border-radius: var(--radius-md); background: var(--panel-2); }
.ap-plan.is-current { box-shadow: inset 0 0 0 2px var(--text); }
.ap-plan-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ap-plan-price { margin: 0; font: 700 20px/1.2 var(--display); letter-spacing: -.01em; }
.ap-plan p { margin: 0; }
.ap-plan ul { display: grid; gap: 4px; margin: 4px 0 8px; padding-left: 20px; color: var(--muted); font-size: 15px; }
.ap-plan .btn { justify-self: start; }

/* Settings */
.ap-group { display: grid; gap: 4px; }
.ap-group > h3 { margin-bottom: 4px; color: var(--subtle); font: 500 13px/1.4 var(--display); }
.ap-setting { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 56px; padding: 8px 0; border-top: 1px solid var(--line); }
.ap-group > h3 + .ap-setting { border-top: 0; }
.ap-setting-name { flex: 1 1 140px; min-width: 0; font: 500 16px/1.35 var(--display); }
.ap-setting-value { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.ap-setting .field-hint { flex: 1 0 100%; }
.ap-setting .btn { max-width: 100%; }
.ap-group > .ap-form { margin: 8px 0; }
.ap-seg { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--panel-3); }
.ap-seg button { min-width: 44px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 500 15px/1 var(--display); cursor: pointer; transition: background-color .15s var(--ease-out), color .15s var(--ease-out); }
.ap-seg button:hover { color: var(--text); }
.ap-seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
:root:not([data-theme="light"]) .ap-seg button[aria-pressed="true"] { background: var(--line-2); box-shadow: none; }
.ap-exit { padding-top: 8px; border-top: 1px solid var(--line); }
.ap-exit .btn { justify-self: start; }

/* Loading */
.ap-skeleton { display: grid; gap: 12px; }
.ap-skeleton span { height: 20px; border-radius: 6px; background: var(--panel-3); }
.ap-skeleton span:nth-child(odd) { width: 70%; }

.profile-button.is-current { background: var(--panel-3); }

/* Motion: a disclosure fades in; the bar eases to its value. Nothing moves under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .ap-form:not([hidden]), .ap-notice:not([hidden]) { animation: ap-in 150ms var(--ease-out) both; }
  .ap-skeleton span { animation: ap-pulse 1.2s ease-in-out infinite; }
}
@keyframes ap-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes ap-pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
  .ap-limit progress::-webkit-progress-value, .account-nav a, .ap-seg button { transition: none; }
}

@media (min-width: 600px) {
  .ap-limit-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ap-plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ap-rows { grid-template-columns: max-content minmax(0, 1fr); }
  .ap-rows dt { margin-top: 0; padding-top: 6px; }
}

/* Two columns: the chips become a column that stays in view while the sections scroll. */
@media (min-width: 851px) {
  .account-layout { grid-template-columns: 200px minmax(0, 1fr); gap: 48px; }
  .account-main { padding-top: 0; max-width: 760px; }
  .account-nav {
    top: 24px; z-index: 1; flex-direction: column; gap: 4px; margin: 0; padding: 0; overflow: visible; background: transparent;
    -webkit-mask-image: none; mask-image: none;
  }
  .account-nav a { min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm); background: transparent; color: var(--muted); }
  .account-nav a:hover { background: var(--hover); color: var(--text); }
  .account-nav a[aria-current="location"] { background: var(--panel-3); color: var(--text); }
  .account-nav a:last-child { margin-right: 0; }
  .account-block { scroll-margin-top: 24px; }
  .account-avatar { width: 72px; height: 72px; font-size: 30px; }
}
@media (max-width: 850px) {
  /* The shell's scroll box would otherwise be the sticky chips' scroller; the page scrolls here. */
  .unified-layout:has(#account-view:not(.hidden)) { overflow: visible; }
}
@media (max-width: 359px) {
  .ap-limit, .ap-plan { padding: 16px; }
  .ap-actions .btn { flex: 1 1 100%; }
}

/* Grids hold long values (an e-mail address) without widening the page. */
.account-main, .account-block, .ap-limits, .ap-limit, .ap-plan, .ap-group, .ap-form, .ap-notice { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) {
  .ap-limit-pair, .ap-plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
