/* Papr admin. Uses the theme's tokens and base styles (css/papr.css); components from
   docs/design/project/Admin.dc.html. */

.admin-wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

.js .nojs {
  display: none;
}

html:not(.js) [data-needs-js] {
  display: none;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

code {
  font-family: var(--mono);
  font-size: .9em;
}

/* --- top bar ------------------------------------------------------------- */

.admin-header {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.admin-nav {
  padding-top: 8px;
  padding-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-name {
  font-size: 14px;
  color: var(--muted);
}

.admin-nav .navlinks {
  gap: 0 26px;
}

.admin-nav form {
  margin: 0;
}

.linkbutton {
  font-family: var(--sans);
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

.flash {
  margin: 20px 0 0;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
}

/* --- forms --------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.field-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
.new-item input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
}

.field textarea {
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.new-item input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.field-value {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: 14.5px;
}

.help {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.btn {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  border-color: transparent;
  color: var(--muted);
  padding: 0 8px;
}

.btn.ghost:hover {
  color: var(--text);
}

.form-error {
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-left: 3px solid #C2410C;
  border-radius: 6px;
  background: var(--surface);
}

.form-error p,
.form-error ul {
  margin: 0;
}

.form-error ul {
  padding-left: 1.2em;
}

/* --- sign in and setup ------------------------------------------------------ */

.card-page {
  padding-top: 64px;
  padding-bottom: 64px;
  flex: 1 0 auto;
}

.card {
  max-width: 420px;
  margin: 0 auto;
  padding: 28px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
}

.card p {
  margin: 0;
}

/* the installer and its welcome */
.card.install {
  max-width: 560px;
}

.install h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.install-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.checks {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checks li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 14.5px;
}

.checks .help {
  display: block;
}

.check-mark {
  flex: 0 0 18px;
  font-weight: 700;
  text-align: center;
}

.check-ok .check-mark {
  color: var(--accent);
}

.check-note .check-mark {
  color: var(--muted);
}

.check-problem .check-mark {
  color: #C2410C;
}

.password-field {
  display: flex;
  gap: 8px;
}

.password-field input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
}

.next-steps {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- lists ------------------------------------------------------------------ */

.list-page {
  padding-top: 32px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
}

.list-head h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
}

.new-item {
  display: flex;
  gap: 10px;
  flex: 0 1 480px;
  min-width: 0;
  max-width: 100%;
}

.new-item input {
  flex: 1 1 auto;
  min-width: 0;
}

.items {
  width: 100%;
  border-collapse: collapse;
}

.items th {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  padding: 0 16px 10px 0;
  border-bottom: 1px solid var(--rule);
}

.items td {
  padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}

.items td a {
  color: var(--text);
  font-weight: 600;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.items td a:hover {
  color: var(--accent);
}

.status {
  font-family: var(--mono);
  font-size: 12px;
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
}

.status-listed,
.status-unlisted {
  border-color: var(--accent);
  color: var(--accent);
}

.status-draft {
  color: var(--muted);
}

.status-changes {
  border-style: dashed;
  color: var(--muted);
}

@media (max-width: 640px) {
  .items thead {
    display: none;
  }

  .items tr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
  }

  .items td {
    padding: 0;
    border: 0;
  }

  .items td:first-child {
    flex: 1 0 100%;
  }
}

/* --- page tree ------------------------------------------------------------- */
.page-tree .depth-1 td:first-child { padding-left: 20px; }
.page-tree .depth-2 td:first-child { padding-left: 40px; }
.page-tree .depth-3 td:first-child { padding-left: 60px; }
.page-tree .depth-4 td:first-child { padding-left: 80px; }

.tree-mark {
  font-family: var(--mono);
  color: var(--muted);
}

.page-tree td.menu-moves-cell {
  padding-right: 0;
  vertical-align: middle;
}

.new-page {
  flex-basis: 680px;
}

.new-page select {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 45%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

@media (max-width: 640px) {
  .page-tree tr[class^="depth-"] td:first-child { padding-left: 0; }

  .new-page {
    flex-wrap: wrap;
  }

  .new-page input {
    flex-basis: 100%;
  }

  .new-page select {
    flex: 1 1 auto;
    max-width: none;
  }
}

/* --- duplicating ----------------------------------------------------------- */
.duplicate summary {
  list-style: none;
  width: fit-content;
}

.duplicate summary::-webkit-details-marker {
  display: none;
}

.duplicate-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}

.duplicate-form input[type="text"] {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.duplicate-form label:not(.check) {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- menu order -------------------------------------------------------------- */
.menu-order {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: menu;
  border-top: 1px solid var(--rule);
}

.menu-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  counter-increment: menu;
}

.menu-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.menu-name::before {
  content: counter(menu) ".";
  display: inline-block;
  min-width: 2.2em;
  font-family: var(--mono);
  font-weight: 400;
  color: var(--muted);
}

.menu-moves {
  display: flex;
  gap: 6px;
  flex: none;
}

.menu-moves .btn {
  min-width: 44px;
  padding: 0 12px;
  font-size: 16px;
}

.menu-moves .btn:disabled {
  opacity: .35;
  cursor: default;
}

/* --- trash ------------------------------------------------------------------- */
.trash-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.trash-items td.mono {
  overflow-wrap: anywhere;
}

.trash-items td.trash-actions {
  padding-right: 0;
  vertical-align: middle;
}

.trash-actions div {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.empty {
  margin: 0;
  padding: 32px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 640px) {
  .trash-items td.trash-actions {
    flex: 1 0 100%;
    padding-top: 6px;
  }

  .trash-actions div {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* --- editor ------------------------------------------------------------------ */

.editor {
  padding-top: 32px;
  padding-bottom: 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 32px 40px;
  align-items: flex-start;
}

.edit-main {
  flex: 999 1 640px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.edit-main .label a {
  color: inherit;
}

.title-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--text);
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.2;
  padding: 6px 0 12px;
}

.title-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.edit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.tool {
  font-family: var(--mono);
  font-size: 13px;
  min-width: 44px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.tool:hover {
  border-color: var(--rule);
  background: var(--surface);
}

.modes {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface);
}

.seg {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.seg.on {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--rule);
}

.panes {
  display: grid;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  min-height: 470px;
}

.panes.split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panes.single {
  grid-template-columns: minmax(0, 1fr);
}

.panes.write .preview,
.panes.preview .md {
  display: none;
}

html:not(.js) .panes {
  grid-template-columns: minmax(0, 1fr);
}

html:not(.js) .panes .preview {
  border-left: 0;
  border-top: 1px solid var(--rule);
}

@media (max-width: 760px) {
  .panes.split {
    grid-template-columns: minmax(0, 1fr);
  }

  .panes.split .preview {
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
}

.md {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 470px;
  border: 0;
  resize: vertical;
  padding: 20px 22px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.75;
}

.md:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* the preview uses the site's prose styles, a little smaller */
.preview.prose {
  max-width: none;
  padding: 20px 26px;
  background: var(--surface);
  border-left: 1px solid var(--rule);
  font-size: 16px;
  line-height: 1.65;
  overflow: auto;
}

.panes.single .preview {
  border-left: 0;
}

.preview.prose > * {
  max-width: none;
}

.preview.prose h2 {
  font-size: 23px;
  margin: 1.3em 0 .5em;
}

.preview.prose code,
.preview.prose pre {
  background: var(--bg);
}

.preview.prose blockquote {
  font-size: 19px;
}

.drop {
  border: 1px dashed var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.drop > .muted {
  font-size: 14.5px;
  flex: 1 1 320px;
}

.drop.over {
  border-color: var(--accent);
  background: var(--surface);
}

.drop-actions {
  display: flex;
  gap: 8px;
}

.drop-status:empty {
  display: none;
}

.drop-status {
  flex: 1 0 100%;
  font-size: 14px;
}

.drop-status.error {
  color: #C2410C;
}

.path {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.settings {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}

.settings .label.strong {
  color: var(--text);
}

.cover-field {
  display: flex;
  gap: 10px;
  align-items: center;
}

.thumb {
  flex: 0 0 72px;
  height: 54px;
  border: 1px solid var(--rule);
  background: var(--bg);
  overflow: hidden;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-field select {
  flex: 1 1 auto;
  min-width: 0;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.buttons .btn {
  flex: 1 1 auto;
}

.settings-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}

.note {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--muted);
}

.restore {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
}

.restore .btn {
  min-height: 36px;
}

/* a published page's unpublished changes */
.changes-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
}

.changes-note p {
  margin: 0;
  flex: 1 1 18em;
}

.changes-note .btn,
.status-value .btn {
  min-height: 36px;
}

.status-value {
  justify-content: space-between;
  gap: 12px;
}

/* --- site settings ------------------------------------------------------------ */

.site-settings {
  padding-top: 32px;
  padding-bottom: 48px;
}

.site-main {
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.site-main h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
}

.site-main > p {
  margin: 0;
}

.fields .buttons .btn {
  flex: 0 0 auto;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

legend {
  padding: 0;
  margin-bottom: 6px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 14.5px;
}

.field label.check {
  font-family: var(--sans);
  font-size: 14.5px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text);
}

.check input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--accent);
}

.field-headline {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}

.rows {
  gap: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 12px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
}

.row > .field {
  flex: 1 1 180px;
}

.row > .btn {
  flex: 0 0 auto;
  margin-top: 22px;
}

/* the spare empty row is for browsers without the script, which adds rows */
.js .row[data-blank-row] {
  display: none;
}

.add-row {
  align-self: flex-start;
}

.cover-field .btn {
  flex: 0 0 auto;
}

/* --- media ---------------------------------------------------------------- */

.upload-to select {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  min-width: 0;
  flex: 1 1 auto;
}

.media-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
}

.media-owner {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.media-owner .mono {
  font-weight: 400;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.media-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.media-card:hover .media-name {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.media-thumb {
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-name {
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.media-card .mono {
  font-size: 12px;
}

.ext {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .08em;
  color: var(--muted);
}

.ext.big {
  font-size: 28px;
  text-decoration: none;
}

.file-title {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-preview {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-preview img {
  display: block;
  max-width: 100%;
  max-height: 520px;
}

.file-facts {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-facts dt {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.file-facts dd {
  margin: 4px 0 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.file-facts dd a {
  color: var(--text);
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.copy-row dd {
  display: flex;
  align-items: center;
  gap: 8px;
}

.replace-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
}

.replace-file .help {
  flex: 1 1 100%;
}

.rename-file {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.rename-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rename-row input {
  flex: 1 1 200px;
  width: auto;
  min-width: 0;
}

/* hidden file inputs show their focus on the button-like label that opens them: the next
   element (Media, Replace file), or one elsewhere on the page (editor, site settings) */
.visually-hidden[type="file"]:focus-visible + label.btn,
body:has(#upload-file:focus-visible) label.btn[for="upload-file"],
.replace-file input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- accounts --------------------------------------------------------------- */

.add-account {
  max-width: 720px;
}

.add-account h2 {
  margin: 0;
  font-weight: 400;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.form-grid .buttons {
  grid-column: 1 / -1;
}

.form-grid .buttons .btn {
  flex: 0 0 auto;
}
