/* ==========================================================================
   PROFILE — HUD console
   Same visual language as the Empty Room: corner-bracket panels, HUD kicker
   rows (blinking gold dot + section index), gold hairline heads, glass depth.
   Dark-mono + JetBrains Mono. Markup and JS hooks unchanged.
   ========================================================================== */

.content:has(#profile-shell),
.content:has(#profile-locked) {
  width: 100%;
  max-width: min(1040px, calc(100vw - 56px));
}

.content-wrap:has(#profile-shell),
.content-wrap:has(#profile-locked) {
  width: 100%;
  max-width: 1100px;
  padding-inline: clamp(16px, 4vw, 44px);
}

#profile-shell,
#profile-shell *,
#profile-locked,
#profile-locked * {
  box-sizing: border-box;
}

#profile-shell[hidden],
#profile-locked[hidden],
.profile-calendar[hidden],
.profile-calendar-toggle[hidden],
.profile-mirror-door[hidden],
.profile-mirror-lines[hidden],
.profile-error[hidden],
.profile-starred[hidden] {
  display: none !important;
}

.profile-shell {
  display: grid;
  width: 100%;
  gap: 16px;
  margin: 0 auto;
  padding: 18px 0 86px;
  color: var(--fg, #e8e8e8);
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
}

/* ---------- Section panels: glass + targeting-frame corners ---------- */
.profile-stairs,
.profile-starred,
.profile-mirror,
.profile-insights,
.profile-discourses {
  position: relative;
  padding: 20px;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.18));
  border-radius: 2px;
  background: rgba(9, 9, 9, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(241, 238, 231, 0.035),
    0 0 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.profile-stairs::before,
.profile-starred::before,
.profile-mirror::before,
.profile-insights::before,
.profile-discourses::before,
.profile-stairs::after,
.profile-starred::after,
.profile-mirror::after,
.profile-insights::after,
.profile-discourses::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  border: 1px solid var(--console-border-strong, rgba(201, 168, 74, 0.42));
  pointer-events: none;
}

.profile-stairs::before,
.profile-starred::before,
.profile-mirror::before,
.profile-insights::before,
.profile-discourses::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

.profile-stairs::after,
.profile-starred::after,
.profile-mirror::after,
.profile-insights::after,
.profile-discourses::after {
  right: -1px;
  bottom: -1px;
  border-left: 0;
  border-top: 0;
}

/* ---------- HUD section head ---------- */
.profile-section-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin: 0 0 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(to right,
    var(--console-border, rgba(201, 168, 74, 0.24)),
    transparent) 1;
}

/* --row keeps the calendar toggle floated right of the stacked head */
.profile-section-head--row {
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.profile-section-head--row > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* HUD kicker: blinking gold dot + uppercase label + per-section index */
#profile-shell .profile-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--console-faint, rgba(241, 238, 231, 0.44));
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

#profile-shell .profile-kicker::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-warm, #c9a84a);
  box-shadow: 0 0 8px rgba(201, 168, 74, 0.6);
  animation: profile-hud-blink 2.4s steps(1, end) infinite;
  flex: 0 0 auto;
}

#profile-shell .profile-kicker::after {
  margin-left: auto;
  color: rgba(201, 168, 74, 0.34);
  letter-spacing: 0.14em;
}

.profile-stairs .profile-kicker::after { content: "/ 01"; }
.profile-starred .profile-kicker::after { content: "/ 02"; }
.profile-mirror .profile-kicker::after { content: "/ 03"; }
.profile-insights .profile-kicker::after { content: "/ 04"; }
.profile-discourses .profile-kicker::after { content: "/ 05"; }

@keyframes profile-hud-blink {
  0%, 62% { opacity: 1; }
  63%, 100% { opacity: 0.15; }
}

.profile-section-head h1,
.profile-section-head h2 {
  max-width: 52ch;
  margin: 0;
  padding: 0;
  border: 0;
  color: rgba(241, 238, 231, 0.92);
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.42;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* dates / small labels inside cards stay quiet */
#profile-shell .profile-mirror-label,
#profile-shell .profile-insight-date,
#profile-shell .profile-discourse-date,
.profile-stair-state {
  margin: 0;
  color: var(--console-faint, rgba(241, 238, 231, 0.44));
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.profile-stair-list,
.profile-starred-list,
.profile-mirror-lines,
.profile-insight-list,
.profile-discourse-list {
  display: grid;
  gap: 8px;
}

/* ---------- Cards ---------- */
.profile-stair,
.profile-star-row,
.profile-mirror-line,
.profile-insight,
.profile-discourse-card {
  position: relative;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.14));
  border-radius: 2px;
  background: rgba(7, 7, 6, 0.4);
  transition: border-color 160ms ease, background 160ms ease;
}

.profile-stair {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.profile-stair-head,
.profile-stair-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.profile-stair-name {
  margin: 0;
  color: rgba(241, 238, 231, 0.92);
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.profile-stair-link,
.profile-mirror-door a,
.profile-calendar-toggle {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.28));
  border-radius: 2px;
  background: rgba(201, 168, 74, 0.04);
  color: var(--console-dim, rgba(241, 238, 231, 0.66));
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 0.14em;
  line-height: 1;
  padding: 7px 12px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.profile-stair-link:hover,
.profile-stair-link:focus-visible,
.profile-mirror-door a:hover,
.profile-mirror-door a:focus-visible,
.profile-calendar-toggle:hover,
.profile-calendar-toggle:focus-visible {
  border-color: var(--console-border-strong, rgba(201, 168, 74, 0.42));
  background: rgba(201, 168, 74, 0.09);
  color: var(--console-text, rgba(241, 238, 231, 0.92));
  outline: none;
}

.profile-star-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 13px;
}

.profile-star-row:hover,
.profile-stair:hover,
.profile-insight:hover,
.profile-discourse-card:hover,
.profile-discourse-card:focus-visible,
.profile-mirror-line:hover {
  border-color: var(--console-border-strong, rgba(201, 168, 74, 0.34));
  background: rgba(201, 168, 74, 0.03);
  outline: none;
}

.profile-star-link {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.profile-star-mark,
.profile-star-remove {
  color: var(--accent-warm, #c9a84a);
}

.profile-star-link strong {
  min-width: 0;
  color: rgba(241, 238, 231, 0.86);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.profile-star-remove {
  flex: 0 0 auto;
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.14));
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}

.profile-star-remove:hover,
.profile-star-remove:focus-visible {
  border-color: var(--console-border-strong, rgba(201, 168, 74, 0.42));
  color: rgba(241, 238, 231, 0.9);
}

.profile-mirror-line,
.profile-insight {
  display: grid;
  grid-template-columns: minmax(120px, 0.24fr) minmax(0, 1fr);
  gap: clamp(14px, 3vw, 28px);
  padding: 14px;
  align-items: baseline;
}

.profile-mirror-line p,
.profile-insight-body p,
.profile-mirror-door p {
  margin: 0;
  color: rgba(241, 238, 231, 0.82);
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 12px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.profile-insight-body p + p { margin-top: 0.85em; }

#profile-shell .profile-insight-latest {
  margin-left: 8px;
  color: var(--accent-warm, #c9a84a);
  letter-spacing: 0.1em;
}

.profile-insight--latest {
  border-color: var(--console-border-strong, rgba(201, 168, 74, 0.32));
  background: rgba(201, 168, 74, 0.04);
}

.profile-mirror-door {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

/* ---------- Calendar ---------- */
.profile-calendar {
  width: min(460px, 100%);
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.14));
  border-radius: 2px;
  background: rgba(7, 7, 6, 0.35);
}

.profile-calendar-head {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
}

.profile-calendar-head p {
  margin: 0;
  text-align: center;
  color: var(--console-dim, rgba(241, 238, 231, 0.66));
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.profile-calendar-head button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.18));
  border-radius: 2px;
  background: rgba(7, 7, 6, 0.5);
  color: var(--console-dim, rgba(241, 238, 231, 0.66));
  cursor: pointer;
}

.profile-calendar-head button:hover,
.profile-calendar-head button:focus-visible {
  border-color: var(--console-border-strong, rgba(201, 168, 74, 0.42));
  color: var(--fg, #e8e8e8);
}

.profile-calendar-weekdays,
.profile-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.profile-calendar-weekdays { margin-top: 12px; }

.profile-calendar-weekdays span {
  padding: 5px 0;
  color: var(--console-faint, rgba(241, 238, 231, 0.44));
  font-size: 9px;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.profile-calendar-day {
  display: grid;
  min-height: 34px;
  border: 0;
  border-top: 1px solid rgba(201, 168, 74, 0.08);
  background: transparent;
  place-items: center;
}

.profile-calendar-day--marked { cursor: pointer; }
.profile-calendar-day--empty { border-top-color: transparent; }
.profile-calendar-day--marked::after {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-warm, #c9a84a);
  box-shadow: 0 0 6px rgba(201, 168, 74, 0.5);
  content: '';
}

/* ---------- Discourses ---------- */
.profile-discourse-card {
  display: grid;
  min-width: 0;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  color: inherit;
  text-decoration: none;
}

.profile-discourse-image,
.profile-discourse-placeholder {
  width: 44px;
  height: 56px;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.16));
  background: rgba(201, 168, 74, 0.03);
  object-fit: cover;
}

.profile-discourse-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.profile-discourse-copy strong {
  color: rgba(241, 238, 231, 0.86);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

/* ---------- HUD placeholders: loading / empty / error ---------- */
#profile-shell .profile-loading,
#profile-shell .profile-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 15px 14px;
  border: 1px dashed var(--console-border, rgba(201, 168, 74, 0.2));
  border-radius: 2px;
  background: rgba(7, 7, 6, 0.28);
  color: var(--console-faint, rgba(241, 238, 231, 0.5));
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

#profile-shell .profile-loading::before {
  content: "\2192"; /* → for in-flight */
  color: rgba(201, 168, 74, 0.5);
  font-weight: 600;
  animation: profile-hud-blink 1.4s steps(1, end) infinite;
}

.profile-error {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(216, 185, 176, 0.24);
  border-radius: 2px;
  background: rgba(216, 185, 176, 0.045);
  color: rgba(241, 238, 231, 0.72);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------- Locked (signed-out) view ---------- */
#profile-locked.admin-locked {
  position: relative;
  max-width: 420px;
  margin: 40px auto 0;
  padding: 26px;
  border: 1px solid var(--console-border, rgba(201, 168, 74, 0.18));
  border-radius: 2px;
  background: rgba(9, 9, 9, 0.6);
  box-shadow: inset 0 1px 0 rgba(241, 238, 231, 0.04), 0 0 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#profile-locked.admin-locked::before,
#profile-locked.admin-locked::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  border: 1px solid var(--console-border-strong, rgba(201, 168, 74, 0.42));
  pointer-events: none;
}

#profile-locked.admin-locked::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

#profile-locked.admin-locked::after {
  right: -1px;
  bottom: -1px;
  border-left: 0;
  border-top: 0;
}

#profile-locked .admin-empty {
  margin: 0 0 16px;
  color: rgba(241, 238, 231, 0.72);
  font: 12px/1.7 var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-locked-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#profile-locked .gate-btn {
  min-height: 36px;
  border-radius: 2px;
  padding: 9px 14px;
  font-size: 10px;
  letter-spacing: 0.14em;
}

@media (max-width: 760px) {
  .content:has(#profile-shell),
  .content:has(#profile-locked) {
    max-width: none;
  }

  .content-wrap:has(#profile-shell),
  .content-wrap:has(#profile-locked) {
    padding-inline: max(14px, env(safe-area-inset-left));
  }

  .profile-shell {
    gap: 12px;
    padding-top: 6px;
  }

  .profile-stairs,
  .profile-starred,
  .profile-mirror,
  .profile-insights,
  .profile-discourses {
    padding: 15px;
  }

  .profile-section-head--row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .profile-stair-head,
  .profile-stair-foot,
  .profile-mirror-door {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .profile-mirror-line,
  .profile-insight {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .profile-discourse-card {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .profile-discourse-image,
  .profile-discourse-placeholder {
    width: 38px;
    height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #profile-shell .profile-kicker::before,
  #profile-shell .profile-loading::before {
    animation: none;
  }
}
