/* Contributor portal. Builds on site.css (tokens, type, buttons, forms, richtext). */

.portal-body { background: var(--paper); }
.portal { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }

/* sidebar */
.p-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px 18px; overflow-y: auto; }
.p-side-top { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 22px; }
.p-side .brand .word { font-size: 19px; }
.p-badge { margin-left: 2px; padding: 2px 7px; border: 1px solid var(--night-line-2); border-radius: 3px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--on-night-2); }
.p-bare .p-badge, .p-top .p-badge { border-color: var(--line-2); color: var(--ink-2); }
.p-close { display: none; width: 36px; height: 36px; border: 0; background: transparent; color: var(--on-night); font-size: 26px; line-height: 1; cursor: pointer; }
.p-nav { display: flex; flex-direction: column; gap: 2px; }
.p-nav a { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 6px; font-size: 15px; font-weight: 520; color: var(--on-night-2); transition: background-color .15s ease, color .15s ease; }
.p-nav a:hover { background: var(--night-2); color: var(--on-night); }
.p-nav a[aria-current="page"] { background: var(--night-3); color: var(--on-night); }
.p-nav a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--violet-bright); }
.p-nav .count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--violet); color: #fff; font-size: 12px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; }
.p-side-foot { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid var(--night-line); }
.p-me { display: flex; gap: 11px; align-items: center; }
.p-me b { display: block; font-size: 14.5px; font-weight: 600; color: var(--on-night); }
.p-me span { font-size: 13px; color: var(--on-night-3); }
.p-side-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: 13.5px; }
.p-side-links a, .p-side-links button { padding: 0; border: 0; background: none; font: inherit; color: var(--on-night-2); cursor: pointer; }
.p-side-links a:hover, .p-side-links button:hover { color: var(--on-night); }

/* main column */
.p-main { min-width: 0; }
.p-top { display: none; }
.p-content { max-width: 1180px; padding: clamp(24px, 4vw, 48px) clamp(18px, 4vw, 48px) 80px; }
.p-content .h2 { font-size: clamp(28px, 3.1vw, 40px); }
.p-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 18px 24px; margin-bottom: 28px; }
.p-head .tag { margin-bottom: 12px; }
.p-head .lead { margin: 10px 0 0; font-size: 17px; }
.p-head .meta { margin-top: 12px; }
.p-h { font-family: var(--serif); font-weight: 420; font-size: 21px; line-height: 1.25; margin: 40px 0 14px; }
.p-note { margin: 12px 0 0; font-size: 14.5px; color: var(--ink-3); }
.p-dim { color: var(--ink-3); font-size: 13.5px; }
.p-flash { margin: 0 0 22px; padding: 12px 16px; border-radius: 6px; font-size: 15px; border: 1px solid; }
.p-flash.ok { background: #eaf5ee; border-color: #b9dcc6; color: #1f5c3c; }
.p-flash.err { background: #fbecee; border-color: #efc0c7; color: #8f1f30; }
.p-empty { padding: 22px; border: 1px dashed var(--line-2); border-radius: 10px; color: var(--ink-3); font-size: 15px; text-align: center; }
.p-pre { white-space: pre-wrap; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }

.av { display: inline-block; flex: none; border-radius: 8px; object-fit: cover; background: var(--paper-2); }
.av-i { display: inline-flex; align-items: center; justify-content: center; background: var(--violet-deep); color: #fff; font-weight: 650; letter-spacing: 0.02em; }
.role { display: inline-flex; align-items: center; height: 21px; padding: 0 7px; border-radius: 3px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-2); color: var(--ink-2); }
.role-author { border-color: #b9d1ea; color: #23557f; }
.role-editor { border-color: #cdbff3; color: var(--violet); }
.role-admin { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* dashboard */
.p-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.p-stat { padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.p-stat-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 560; color: var(--ink-2); }
.p-stat b { display: block; margin-top: 8px; font-family: var(--serif); font-weight: 360; font-size: 38px; line-height: 1; letter-spacing: -0.015em; }
.p-stat-note { display: block; margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2fa866; box-shadow: 0 0 0 0 rgba(47, 168, 102, 0.5); animation: live 2s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(47, 168, 102, 0.45); } 70% { box-shadow: 0 0 0 8px rgba(47, 168, 102, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 168, 102, 0); } }
.p-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.p-panel { padding: 20px 22px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
section.p-panel { margin-top: 20px; }
.p-cols > .p-panel { margin-top: 0; }
.p-panel .p-h { margin-top: 0; font-size: 19px; }
.p-wide { grid-column: 1 / -1; }
.p-chart { width: 100%; height: auto; }
.p-chart rect { fill: var(--violet); opacity: .82; }
.p-chart rect:hover { opacity: 1; }
.p-chart text { font: 500 10px var(--sans); fill: var(--ink-3); }
.p-mini li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.p-mini li:first-child { border-top: 0; padding-top: 2px; }
.p-mini li > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.p-mini li a { color: var(--ink); font-weight: 560; }
.p-mini li a:hover { color: var(--violet); }
.p-mini li > span:last-child, .p-mini li > b { flex: none; color: var(--ink-3); font-size: 13.5px; text-align: right; }
.p-mini li > b { color: var(--ink); font-weight: 600; font-size: 14.5px; }
.p-mini li.new a::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; background: var(--violet); vertical-align: 1px; }

/* lists of rows (threads, events, posts) */
.p-list { border-top: 1px solid var(--line-2); }
.p-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 4px; border-bottom: 1px solid var(--line); transition: background-color .15s ease; }
.p-row:hover { background: rgba(22, 19, 27, 0.025); }
.p-row-main { min-width: 0; }
.p-row-title { display: block; font-family: var(--serif); font-size: 19.5px; line-height: 1.3; color: var(--ink); }
.p-row.unread .p-row-title::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 10px; background: var(--violet); vertical-align: 2px; }
.p-row-meta { display: block; margin-top: 3px; font-size: 14px; color: var(--ink-3); }
.p-row-side { flex: none; text-align: right; font-size: 14px; color: var(--ink-2); }
.p-row-side span { color: var(--ink-3); font-size: 13px; }
.p-row-side .pend { color: var(--violet); font-weight: 600; }
.pin { display: inline-block; margin-right: 8px; padding: 1px 6px; border-radius: 3px; background: var(--paper-2); font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--ink-2); vertical-align: 3px; }
.p-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.p-tile { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s ease; }
.p-tile:hover { border-color: var(--line-2); }
.p-tile-title { font-family: var(--serif); font-size: 21px; }
.p-tile-text { font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
.p-tile-meta { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--ink-3); }

/* threads */
.p-thread { border-top: 1px solid var(--line-2); }
.p-post { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 16px; padding: 22px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 24px; }
.p-post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; color: var(--ink-3); margin-bottom: 8px; }
.p-post-meta b { font-size: 15px; color: var(--ink); font-weight: 620; }
.p-rt { font-size: 16.5px; line-height: 1.65; max-width: 48em; }
.p-rt h2 { font-size: 24px; } .p-rt h3 { font-size: 20px; }
.p-post-actions { display: flex; gap: 14px; margin-top: 10px; font-size: 13.5px; }
.p-post-actions a, .p-post-actions button { padding: 0; border: 0; background: none; font: inherit; color: var(--ink-3); cursor: pointer; }
.p-post-actions a:hover, .p-post-actions button:hover { color: var(--ink); }
.p-modbar { display: flex; gap: 8px; }
.p-reply { margin-top: 28px; max-width: none; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line-2); border-left: 1px solid var(--line); }
.cal .dow { padding: 8px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-3); background: var(--paper-2); }
.cal .day { min-height: 118px; padding: 6px 6px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card); min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cal .day.out { background: transparent; }
.cal .day.out .dnum { color: var(--ink-3); opacity: .6; }
.cal .dnum { align-self: flex-start; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.cal .day.today .dnum { background: var(--violet); color: #fff; }
.cal .ev { display: block; padding: 3px 6px; border-radius: 3px; border-left: 3px solid var(--violet); background: rgba(91, 54, 214, 0.08); font-size: 12.5px; line-height: 1.35; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev span { margin-right: 5px; font-weight: 600; color: var(--violet); }
.cal .ev:hover { background: rgba(91, 54, 214, 0.16); }
.cal .ev.private { border-left-color: var(--ink-2); background: rgba(22, 19, 27, 0.06); }
.cal .ev.private span { color: var(--ink-2); }
.cal .ev.pending { border-left-style: dotted; }
.cal .ev.cancelled { text-decoration: line-through; opacity: .55; }
.cal .more-ev { font-size: 12px; color: var(--ink-3); padding-left: 6px; }
.p-rsvp { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.p-rsvp > span { margin-right: 8px; font-weight: 600; font-size: 15px; }
.p-rsvp .btn { height: 38px; }
.p-people li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.p-people li:first-child { border-top: 0; }
.p-people em { margin-left: auto; font-style: normal; font-size: 13px; color: var(--ink-3); }
.people { border: 0; padding: 0; margin: 0; }
.people legend { font-size: 14px; font-weight: 560; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; }
.pair { display: flex; gap: 8px; }
.pair > input { min-width: 0; }
.pair.prefix { align-items: center; border: 1px solid var(--line-2); border-radius: 4px; background: var(--card); padding-left: 12px; }
.pair.prefix em { font-style: normal; color: var(--ink-3); font-size: 15px; }
.pair.prefix input { border: 0 !important; box-shadow: none !important; background: transparent !important; padding-left: 4px !important; }
.form .row3 { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 16px; }

/* writing */
.st { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 3px; font-size: 12.5px; font-weight: 600; background: var(--paper-2); color: var(--ink-2); }
.st-pub { background: #e3f2e8; color: #1f5c3c; }
.st-submitted { background: rgba(91, 54, 214, 0.12); color: var(--violet); }
.st-changes { background: #fbf0dc; color: #7a4d0b; }
.p-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: -10px 0 22px; font-size: 14.5px; color: var(--ink-2); }
.p-review-note { flex-basis: 100%; padding: 14px 16px; background: #fbf0dc; border: 1px solid #ecd2a2; border-radius: 8px; }
.p-review-note b { display: block; margin-bottom: 6px; font-size: 14px; }
.p-editor { max-width: none; }
.p-editor fieldset { display: grid; gap: 20px; border: 0; padding: 0; margin: 0; min-width: 0; }
.p-editor fieldset[disabled] { opacity: .7; }
.p-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.p-split > .f { align-content: start; }
.p-split textarea { min-height: 560px; font-family: var(--mono); font-size: 14px; line-height: 1.6; }
.p-preview { min-height: 560px; max-height: 760px; overflow-y: auto; padding: 18px 20px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); font-size: 16px; }
.p-preview h2 { font-size: 24px; } .p-preview h3 { font-size: 20px; }
.p-cover { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.p-cover img { width: 160px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.p-cover small { flex-basis: 100%; font-size: 13px; color: var(--ink-3); }
.p-avatar-edit img[data-cover-img] { width: 72px; height: 72px; border-radius: 8px; }
.p-actions { position: sticky; bottom: 0; z-index: 5; padding: 14px 0; margin-top: 4px; background: var(--paper); border-top: 1px solid var(--line); }
.p-changes summary { cursor: pointer; font-weight: 600; }
.p-changes form { margin-top: 14px; }

/* members, settings */
.p-people-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.p-person { display: flex; gap: 16px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; scroll-margin-top: 24px; }
.p-person:target { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(91, 54, 214, 0.12); }
.p-person b { font-family: var(--serif); font-weight: 420; font-size: 20px; }
.p-person .handle { font-size: 13.5px; color: var(--ink-3); }
.p-person-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.p-person p { margin: 10px 0 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.55; }
.p-person-contact { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13.5px; color: var(--ink-3); }
.p-person-contact a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.p-invite { max-width: none; margin-bottom: 22px; padding: 20px 22px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.p-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.p-table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-3); padding: 0 12px 10px 0; border-bottom: 1px solid var(--line-2); }
.p-table td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.p-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.p-inline select { min-height: 38px; padding: 6px 30px 6px 10px; border: 1px solid var(--line-2); border-radius: 4px; background-color: var(--card); font: inherit; font-size: 14px;
  appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.p-inline .btn { height: 38px; }
.p-inline .check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); }
.p-copy { display: flex; gap: 8px; max-width: 760px; margin: 8px 0 12px; }
.p-copy input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--card); font-family: var(--mono); font-size: 13px; color: var(--ink-2); }

/* sign-in */
.p-gate { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 40px 20px; }
.p-card { width: min(100%, 460px); padding: 34px 32px 28px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.p-card .h3 { margin-bottom: 12px; }
.p-card p { color: var(--ink-2); font-size: 15.5px; }
.p-card .form { margin: 22px 0 18px; }
.p-gate-foot { display: flex; gap: 18px; font-size: 13.5px; color: var(--ink-3); }
.p-gate-foot a:hover { color: var(--ink); }

/* small screens: the sidebar becomes a drawer */
@media (max-width: 960px) {
  .portal { grid-template-columns: minmax(0, 1fr); }
  .p-side { position: fixed; z-index: 80; left: 0; top: 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .22s ease; }
  .p-side.open { transform: none; box-shadow: 20px 0 50px -20px rgba(0, 0, 0, 0.5); }
  .p-close { display: block; }
  .p-top { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 40; height: 58px; padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
  .p-menu { width: 40px; height: 40px; margin-left: -8px; border: 0; background: transparent; cursor: pointer; }
  .p-menu span { display: block; width: 20px; height: 1.5px; margin: 5px auto; background: var(--ink); }
  .p-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .p-cols, .p-people-grid, .p-split { grid-template-columns: minmax(0, 1fr); }
  .p-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal .day { min-height: 84px; }
  .form .row3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .p-stats, .p-tiles { grid-template-columns: minmax(0, 1fr); }
  .cal .dow { font-size: 11px; padding: 6px 4px; }
  .cal .day { min-height: 64px; padding: 4px 2px; }
  .cal .ev { font-size: 11px; padding: 2px 4px; border-left-width: 2px; }
  .cal .ev span { display: none; }
  .p-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .p-row-side { text-align: left; }
  .pair { flex-direction: column; }
}
