/* ==========================================================================
   Dev Hub — shared.css
   Design tokens, resets, and components reused across two or more pages.
   Page-specific rules live in that page's own stylesheet.
   ========================================================================== */

:root {
  --ink: #0a0a0a;
  --paper: #ffffff;
  --muted: #6b6b6b;
  --line: #d8d8d8;
  --panel: #f6f6f4;
  --critical-bg: #0a0a0a;
  --critical-fg: #ffffff;
  --success: #15803d;
  --error: #b91c1c;
  --header-h: 4.5rem;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
}

body {
  font-family: 'Archivo', sans-serif;
  color: var(--ink);
}

h1, h2 {
  font-family: 'Fraunces', serif;
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

/* Generic keyboard-focus ring for interactive elements */
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- Section titles (index + editor pages) ---------- */
.section-title {
  font-size: 1.05rem;
  margin: 2.75rem 0 0.9rem;
}

.section-title--first {
  margin-top: 0;
}

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  padding: 0.55rem 0.95rem;
  border-radius: 5px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.82rem;
  font-weight: 600;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover:not(:disabled) {
  opacity: 0.85;
}

.btn.secondary {
  background: var(--paper);
  color: var(--ink);
}

.btn.danger {
  background: var(--paper);
  color: var(--error);
  border-color: var(--error);
}

.btn.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.btn.btn-error {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.icon-btn:hover:not(:disabled) {
  background: var(--panel);
}

/* ---------- Editor page chrome (announce + builds) ---------- */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.nav-back {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.nav-back:hover {
  text-decoration: underline;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.header-text {
  min-width: 0;
}

.header-row h1 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
}

.lede {
  color: var(--muted);
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.editor-layout h2 {
  font-size: 1.05rem;
  margin: 0 0 0.85rem;
}

/* ---------- Panels & status ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  background: var(--panel);
  margin-bottom: 2rem;
}

.token-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.status-bar {
  margin-bottom: 1.5rem;
  min-height: 1.2em;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-bar.ok {
  color: var(--success);
  font-weight: 600;
}

.status-bar.error {
  color: var(--error);
  font-weight: 600;
}

/* ---------- Forms ---------- */
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="date"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
}

textarea {
  resize: vertical;
  min-height: 3.5rem;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
}

/* ---------- Editor layout: two-pane grid ---------- */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

#cardList {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem;
  background: var(--paper);
  min-width: 0;
}

.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #f0f0f0;
  gap: 0.75rem;
}

.card-index {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
  min-width: 0;
}

@media (min-width: 620px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-grid .span-2 {
    grid-column: 1 / -1;
  }
}

#addCardBtn {
  width: 100%;
  padding: 0.8rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

#addCardBtn:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.empty-state {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 1rem 0;
}

/* ---------- Live-preview sidebar (announce + builds editors) ---------- */
.preview-sidebar {
  position: static;
  min-width: 0;
}

@media (min-width: 960px) {
  .preview-sidebar {
    position: sticky;
    top: 2rem;
  }
}

.preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.preview-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-canvas {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  background: #fafaf9;
  min-height: 14rem;
  overflow-x: hidden;
}

.preview-empty {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 2rem 0;
}

/* ---------- Badges (build previews + download page) ---------- */
.badge-tag {
  font-family: 'Archivo', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 3px;
}

.badge-latest { background: var(--ink); color: var(--paper); }
.badge-type { background: #e5e5e5; color: #333; }
.badge-tag-custom { background: #e0f2fe; color: #0369a1; }
.badge-archived { background: #cbd5e1; color: #334155; }

/* ---------- Announcement card (Dev Hub feed + editor preview) ---------- */
.announcement-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  font-size: 0.88rem;
  line-height: 1.45;
  background: var(--paper);
  color: var(--ink);
}

.announcement-card.critical {
  background: var(--critical-bg);
  color: var(--critical-fg);
  border-color: var(--critical-bg);
}

.ann-title {
  margin: 0;
  font-weight: 600;
}

.ann-subtitle {
  margin: -0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.announcement-card.critical .ann-subtitle {
  color: #d9d9d9;
}

.ann-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.announcement-card.critical .ann-meta {
  color: #d9d9d9;
}

.ann-meta span {
  display: none;
}

.ann-meta span.has-value {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.ann-readmore {
  display: none;
  align-self: flex-start;
  padding: 0;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  color: inherit;
}

.ann-readmore.has-value {
  display: inline-block;
}

.ann-note {
  font-size: 0.85rem;
  color: var(--muted);
}

.announcement-card.critical .ann-note {
  color: #d9d9d9;
}

.ann-note[hidden] {
  display: none;
}

.ann-link-btn {
  display: none;
  align-self: flex-start;
  padding: 0.5rem 0.85rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--ink);
  color: var(--paper);
}

.announcement-card.critical .ann-link-btn {
  background: var(--paper);
  color: var(--ink);
}

.ann-link-btn.has-value {
  display: inline-block;
}
