/*
 * Preview — Ordinal-inspired components (see foundation.css for tokens + resets).
 */

/* ——— Auth layout ——— */
.auth-body {
  min-height: 100vh;
}

.auth-canvas {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.auth-canvas__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 28rem;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 1rem;
}

.auth-canvas__brand {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: hsl(var(--foreground));
}

.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 28rem;
  margin: 0 auto;
  width: 100%;
}

/* ——— Admin shell ——— */
.admin-app {
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

.app-sidebar {
  width: 16.9375rem; /* ~271px */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}

.app-sidebar__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1rem 0.75rem;
}

.app-sidebar__brand {
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  text-decoration: none;
  color: hsl(var(--foreground));
}

.app-sidebar__title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.app-sidebar__badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  align-self: flex-start;
  padding: 0.125rem 0.45rem;
  border-radius: 999px;
  background: hsl(var(--muted));
}

.app-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  flex: 1;
}

.app-sidebar__link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.app-sidebar__link:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  text-decoration: none;
}

.app-sidebar__link--active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.app-sidebar__footer {
  padding: 0.75rem 1rem 1rem;
  margin-top: auto;
  border-top: 1px solid hsl(var(--border));
}

.app-sidebar__footer .button_to {
  display: block;
  margin: 0;
}

.app-sidebar__footer .button_to button {
  width: 100%;
}

.app-shell__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: hsl(var(--background));
}

.app-page {
  flex: 1;
  max-width: 68rem;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

@media (max-width: 640px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border));
  }

  .app-sidebar__top {
    flex: 1;
    min-width: 0;
  }

  .app-sidebar__nav {
    flex-direction: row;
    flex: 1 1 100%;
    padding-top: 0;
  }

  .app-sidebar__footer {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    width: 100%;
  }
}

/* ——— Buttons ——— */
.btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.5rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

.btn:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

.btn:disabled,
.button:disabled,
.btn[aria-disabled="true"],
.button[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.btn--primary,
.button:not(.button--ghost):not(.button--danger):not(.button--outline) {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.btn--primary:hover,
.button:not(.button--ghost):not(.button--danger):not(.button--outline):hover {
  background: hsl(var(--primary) / 0.9);
  text-decoration: none;
}

.btn--outline,
.button--outline {
  border-color: hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.btn--outline:hover,
.button--outline:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn--ghost,
.button--ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: hsl(var(--foreground));
}

.btn--ghost:hover,
.button--ghost:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn--destructive,
.button--danger {
  background: transparent;
  color: hsl(var(--destructive));
  border-color: hsl(var(--border));
  box-shadow: none;
}

.btn--destructive:hover,
.button--danger:hover {
  background: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.35);
}

.btn--sm,
.button--sm {
  min-height: 2rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: none;
}

.btn--icon {
  width: 2.25rem;
  min-width: 2.25rem;
  padding: 0;
}

.btn--sidebar {
  justify-content: center;
}

/* ——— Cards & panels ——— */
.card,
.panel {
  border-radius: var(--radius-xl);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.card--auth {
  max-width: 24rem;
  width: 100%;
  margin: 0 auto;
}

.card__header {
  padding: 1.5rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.card__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
}

.card__description {
  margin: 0;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.card__content {
  padding: 1.5rem;
  padding-top: 1.25rem;
}

.panel--pad {
  padding: 1.25rem 1.35rem;
}

/* ——— Forms ——— */
.stack-form .field {
  margin-bottom: 1rem;
}

.stack-form .field:last-of-type {
  margin-bottom: 0;
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.field--inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.label--inline {
  margin-bottom: 0;
  font-weight: 400;
}

.input,
.stack-form input[type="text"],
.stack-form input[type="number"],
.stack-form input[type="url"],
.stack-form input[type="email"],
.stack-form input[type="password"],
.stack-form input[type="search"],
.stack-form textarea {
  display: block;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background: transparent;
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.stack-form textarea {
  min-height: 2.25rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.input::placeholder,
.stack-form input::placeholder,
.stack-form textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

.input:focus-visible,
.stack-form input:focus-visible,
.stack-form textarea:focus-visible {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

.input:disabled,
.stack-form input:disabled,
.stack-form textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.stack-form textarea.monospace {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  min-height: 11rem;
  resize: vertical;
}

.checkbox {
  width: 1rem;
  height: 1rem;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid hsl(var(--primary));
  accent-color: hsl(var(--primary));
  cursor: pointer;
}

.field-hint {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.45;
}

.field-hint code {
  font-size: 0.78em;
}

.field-hint a {
  color: hsl(var(--foreground));
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.field-hint a:hover {
  color: hsl(var(--primary));
}

.form-errors {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--destructive) / 0.35);
  background: hsl(var(--destructive) / 0.08);
}

.form-errors__title {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--destructive));
}

.form-errors__list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 1.15rem 1.35rem 1.35rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.35);
}

.form-actions--bare {
  padding: 1.25rem 0 0;
  margin-top: 0.25rem;
  border-top: none;
  background: transparent;
}

.devise-links {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid hsl(var(--border));
}

.devise-links p {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
}

.devise-links p:last-child {
  margin-bottom: 0;
}

.form-section {
  padding: 1.35rem 1.35rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.form-section:last-of-type {
  border-bottom: none;
}

.form-section__title {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}

/* ——— Flash ——— */
.flash {
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 0.875rem;
}

.flash--notice {
  background: hsl(142 76% 36% / 0.1);
  color: hsl(var(--foreground));
}

.flash--alert {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--foreground));
}

.admin-flash {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0.75rem 1.25rem 0;
  width: 100%;
}

.admin-flash .flash {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 0.5rem;
}

/* ——— Page chrome ——— */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-head__text {
  min-width: 0;
}

.page-title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  max-width: 36rem;
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ——— Tables ——— */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid hsl(var(--border));
}

.data-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.35);
}

.data-table__th--right {
  width: 1%;
  text-align: right;
}

.data-table__date {
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: hsl(var(--muted) / 0.25);
}

.data-table__slug {
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.data-table__slug a {
  color: hsl(var(--foreground));
  text-decoration: none;
}

.data-table__slug a:hover {
  color: hsl(var(--primary));
  text-decoration: underline;
}

.data-table__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  justify-content: flex-end;
}

.data-table__actions form.button_to {
  display: inline;
  margin: 0;
}

/* ——— Empty state ——— */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius-xl);
  background: hsl(var(--card));
}

.empty-state__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.empty-state__text {
  margin: 0 0 1.25rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
}

/* ——— Background choice (form) ——— */
.bg-choice {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .bg-choice {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }
}

.bg-choice__box {
  padding: 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.25);
}

.bg-choice__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.65rem;
}

.file-input input[type="file"] {
  width: 100%;
  max-width: 100%;
  padding: 0.45rem 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.thumb-preview {
  display: block;
  max-width: 100%;
  width: auto;
  max-height: 10rem;
  margin-top: 0.65rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

/* ——— Detail blocks ——— */
.detail-grid {
  display: grid;
  gap: 1rem;
}

.detail-block {
  padding: 1rem 1.15rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.detail-block dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  margin: 0 0 0.35rem;
}

.detail-block dd {
  margin: 0;
  font-size: 0.875rem;
}

.url-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.url-line code {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--muted) / 0.4);
  border: 1px solid hsl(var(--border));
  font-family: var(--font-mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.embed-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  padding: 0.85rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  background: hsl(var(--muted) / 0.25);
  max-height: 16rem;
  overflow: auto;
}

.text-link {
  color: hsl(var(--foreground));
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: 0.875rem;
  font-weight: 500;
}

.text-link:hover {
  color: hsl(var(--primary));
}

.muted {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

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