/* Darkmatter — canonical CSS for Andromeda apps.
 * Source of truth for reset, tokens, and shared components.
 * Docs: /darkmatter
 */

@font-face {
  font-family: "Commit Mono";
  src: url("/assets/fonts/CommitMono-400-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Commit Mono";
  src: url("/assets/fonts/CommitMono-700-Regular.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Reset + webkit hardening ─────────────────────────────────────── */

*,
*::before,
*::after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Commit Mono", monospace, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html {
  background: #121113;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: start;
  align-items: start;
  gap: 1.5rem;
  min-height: 100vh;
  max-width: 700px;
  margin: auto;
  padding: 0 1rem 4rem;
}

@media (max-width: 480px) {
  body {
    padding: 1rem;
    gap: 1rem;
  }
}

/* ── Links ────────────────────────────────────────────────────────── */

a {
  color: #ffffff;
  text-decoration: none;
  touch-action: manipulation;
}

a:hover {
  opacity: 0.7;
}

/* ── Header / nav ─────────────────────────────────────────────────── */

.header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  margin-top: 2rem;
  border-bottom: 1px solid #333;
  padding-bottom: 1rem;
}

.logo {
  font-size: 28px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 12px;
}

/* ── Main ─────────────────────────────────────────────────────────── */

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Forms ────────────────────────────────────────────────────────── */

.form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.form-row .form-field {
  flex: 1;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .form-row {
    flex-direction: column;
  }
}

label {
  font-size: 12px;
  opacity: 0.7;
}

input,
textarea,
select {
  background: #121113;
  color: #ffffff;
  border: 1px solid #ffffff;
  padding: 0.4rem 0.75rem;
  font-size: 16px; /* 16px prevents iOS focus zoom */
  width: 100%;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
}

textarea {
  min-height: 400px;
  resize: vertical;
}

select {
  background-image: none;
  padding-right: 0.75rem;
}

input[type="file"] {
  cursor: pointer;
  font-size: 14px;
}

input[type="file"]::-webkit-file-upload-button,
input[type="file"]::file-selector-button {
  background: #121113;
  color: #ffffff;
  border: 1px solid #555;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-family: "Commit Mono", monospace;
  font-size: 12px;
  margin-right: 0.5rem;
  border-radius: 0;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: transparent;
  border: 1px solid #ffffff;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  touch-action: manipulation;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:checked::after {
  content: '✔︎';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #ffffff;
  line-height: 1;
}

input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
}

.checkbox-field {
  justify-content: flex-end;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 14px;
  opacity: 1;
  cursor: pointer;
}

/* Switch */

.switch-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.switch-label {
  font-size: 14px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #333;
  border-radius: 20px;
  transition: background 0.2s;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: #888;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .switch-slider {
  background: #555;
}

.switch input:checked + .switch-slider::before {
  transform: translateX(16px);
  background: #ffffff;
}

/* ── Buttons ──────────────────────────────────────────────────────── */

button,
.btn {
  background: #121113;
  color: #ffffff;
  padding: 0.2rem 0.75rem;
  border: 1px solid #ffffff;
  cursor: pointer;
  width: fit-content;
  font-size: 14px;
  line-height: 1.4;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
  display: inline-block;
  touch-action: manipulation;
}

button:hover,
.btn:hover {
  opacity: 0.7;
}

button.loading {
  cursor: wait;
}

.link-button {
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.link-button:hover {
  opacity: 0.7;
}

.link-button.danger {
  opacity: 0.5;
}

.link-button.danger:hover {
  opacity: 0.3;
}

.inline-form {
  display: inline;
  margin: 0;
  padding: 0;
}

/* ── Feedback ─────────────────────────────────────────────────────── */

.error {
  color: #ffffff;
  border-left: 2px solid #ffffff;
  padding-left: 0.5rem;
  font-size: 13px;
  opacity: 0.8;
}

.success {
  color: #ffffff;
  border-left: 2px solid #555;
  padding-left: 0.5rem;
  font-size: 13px;
  opacity: 0.7;
}

.empty {
  opacity: 0.5;
  font-size: 12px;
}

/* ── Item list (generic stacked list pattern) ────────────────────── */

.item-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #333;
}

.item:hover {
  opacity: 0.7;
}

.item-title {
  font-size: 16px;
}

.item-meta {
  font-size: 12px;
  opacity: 0.5;
}

/* ── Admin list (horizontal row w/ actions) ──────────────────────── */

.admin-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.admin-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #333;
  gap: 1rem;
}

.admin-list-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.admin-list-title {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-list-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.admin-list-date {
  font-size: 11px;
  opacity: 0.4;
}

.admin-list-actions {
  display: flex;
  gap: 1rem;
  font-size: 12px;
  flex-shrink: 0;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.admin-toolbar h2 {
  font-size: 18px;
  font-weight: 700;
}

@media (max-width: 480px) {
  .admin-list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ── Tags / badges ───────────────────────────────────────────────── */

.tag {
  font-size: 11px;
  opacity: 0.5;
  background: #1e1c1f;
  padding: 1px 6px;
  border: 1px solid #333;
}

.status-badge {
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid #333;
}

.status-published {
  opacity: 1;
  border-color: #555;
}

.status-draft {
  opacity: 0.4;
}

/* ── Tables ──────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  opacity: 0.5;
  font-weight: 400;
  font-size: 12px;
  text-transform: uppercase;
  text-align: left;
  padding: 6px;
  border-bottom: 1px solid #333;
}

td {
  padding: 6px;
  border-bottom: 1px solid #333;
}

/* ── Spinner (braille) ────────────────────────────────────────────── */

.spinner {
  margin-left: 0.6rem;
}

.spinner::after {
  content: "⠋";
  display: inline-block;
  animation: braille-spin 0.8s steps(10) infinite;
}

@keyframes braille-spin {
  0%   { content: "⠋"; }
  10%  { content: "⠙"; }
  20%  { content: "⠹"; }
  30%  { content: "⠸"; }
  40%  { content: "⠼"; }
  50%  { content: "⠴"; }
  60%  { content: "⠦"; }
  70%  { content: "⠧"; }
  80%  { content: "⠇"; }
  90%  { content: "⠏"; }
}

/* ── Inline code ─────────────────────────────────────────────────── */

code {
  background: #1e1c1f;
  padding: 2px 4px;
  font-size: 13px;
}

pre {
  background: #1e1c1f;
  padding: 12px;
  overflow-x: auto;
  border: 1px solid #333;
  -webkit-overflow-scrolling: touch;
}

pre code {
  background: none;
  padding: 0;
}

/* ── Footer ──────────────────────────────────────────────────────── */

.footer {
  width: 100%;
  border-top: 1px solid #333;
  padding-top: 1rem;
  margin-top: auto;
  display: flex;
  justify-content: center;
}

/* ── Utility ─────────────────────────────────────────────────────── */

.hidden {
  display: none;
}

.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
