/* Modern Light/Dark Design System for earnieboyd.com */
:root {
  --bg-light: #f4f7fb;
  --bg-dark: #0b1120;
  --surface-light: #ffffff;
  --surface-dark: #131c31;
  --surface-subtle-light: #eef3fa;
  --surface-subtle-dark: #1a2642;
  --text-light: #0f172a;
  --text-dark: #f1f5f9;
  --muted-light: #475569;
  --muted-dark: #94a3b8;
  --border-light: #cbd5e1;
  --border-dark: #293856;
  --brand-light: #1d4ed8;
  --brand-dark: #38bdf8;
  --brand-contrast-light: #ffffff;
  --brand-contrast-dark: #082f49;
  --danger-light: #b91c1c;
  --danger-dark: #f87171;
  --danger-bg-light: #fef2f2;
  --danger-bg-dark: #3b1219;
  --success-light: #15803d;
  --success-dark: #4ade80;
  --focus-light: #2563eb;
  --focus-dark: #7dd3fc;

  --bg: var(--bg-light);
  --surface: var(--surface-light);
  --surface-subtle: var(--surface-subtle-light);
  --text: var(--text-light);
  --muted: var(--muted-light);
  --border: var(--border-light);
  --brand: var(--brand-light);
  --brand-contrast: var(--brand-contrast-light);
  --danger: var(--danger-light);
  --danger-bg: var(--danger-bg-light);
  --success: var(--success-light);
  --focus: var(--focus-light);
  --shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.12);

  @media (prefers-color-scheme: dark) {
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-subtle: var(--surface-subtle-dark);
    --text: var(--text-dark);
    --muted: var(--muted-dark);
    --border: var(--border-dark);
    --brand: var(--brand-dark);
    --brand-contrast: var(--brand-contrast-dark);
    --danger: var(--danger-dark);
    --danger-bg: var(--danger-bg-dark);
    --success: var(--success-dark);
    --focus: var(--focus-dark);
    --shadow: 0 14px 36px -12px rgba(2, 6, 23, 0.65);
  }

  @supports (color: light-dark(white, black)) {
    --bg: light-dark(var(--bg-light), var(--bg-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --surface-subtle: light-dark(var(--surface-subtle-light), var(--surface-subtle-dark));
    --text: light-dark(var(--text-light), var(--text-dark));
    --muted: light-dark(var(--muted-light), var(--muted-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --brand: light-dark(var(--brand-light), var(--brand-dark));
    --brand-contrast: light-dark(var(--brand-contrast-light), var(--brand-contrast-dark));
    --danger: light-dark(var(--danger-light), var(--danger-dark));
    --danger-bg: light-dark(var(--danger-bg-light), var(--danger-bg-dark));
    --success: light-dark(var(--success-light), var(--success-dark));
    --focus: light-dark(var(--focus-light), var(--focus-dark));
  }

  color-scheme: light dark;
  accent-color: var(--brand);
  scrollbar-color: var(--muted) transparent;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(29, 78, 216, 0.12), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(14, 165, 233, 0.12), transparent 38%);
}

/* Public Link Hub */
.hub-shell {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 3.5rem 1.25rem 2.5rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hub-header {
  text-align: center;
  margin-bottom: 2.25rem;
}

.avatar-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 20px;
  background: linear-gradient(135deg, #1e3a8a, #0284c7);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px -8px rgba(2, 132, 199, 0.45);
}

.avatar-badge-sm {
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 12px;
  font-size: 1rem;
  flex-shrink: 0;
}

.hub-title {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.hub-bio {
  margin: 0.5rem auto 0;
  max-width: 48ch;
  color: var(--muted);
  font-size: 1rem;
}

.hub-links-section {
  flex: 1;
}

.hub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.hub-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.hub-link-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}

.hub-link-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .hub-link-card {
    transition: border-color 0.15s ease;
  }
  .hub-link-card:hover {
    transform: none;
  }
}

.hub-link-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.hub-link-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.35;
}

.hub-link-desc {
  color: var(--muted);
  font-size: 0.9rem;
}

.hub-link-host {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 0.1rem;
}

.hub-link-indicator {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.hub-footer {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 2.25rem 1.5rem;
  text-align: center;
}

.notfound-card {
  border-style: solid;
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.notfound-actions {
  margin-top: 0.75rem;
}

.empty-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.empty-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Admin Layout & Cards */
.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.auth-back {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.auth-back a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

.admin-shell {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

.admin-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.topbar-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.topbar-user {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

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

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.25rem 0 1.5rem;
}

.tab-btn {
  appearance: none;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 1.05rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.tab-btn.is-active {
  background: var(--brand);
  color: var(--brand-contrast);
  border-color: var(--brand);
}

.tab-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.badge-pill {
  font-size: 0.75rem;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.18);
  color: inherit;
}

.tab-btn.is-active .badge-pill {
  background: rgba(255, 255, 255, 0.22);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
}

.card-subtitle {
  margin: 0.25rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Forms & Post-Interaction Validation */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 650;
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
}

.optional-tag {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
}

.hint {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--brand);
}

.error-msg {
  display: none;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 550;
  margin-top: 0.35rem;
}

:is(input:user-invalid, input.user-invalid-fallback) {
  border-color: var(--danger);
  background-color: var(--danger-bg);
}

:is(input:user-invalid, input.user-invalid-fallback) + .error-msg {
  display: block;
}

.shortcode-input-group:has(:is(input:user-invalid, input.user-invalid-fallback)) + .error-msg {
  display: block;
}

.shortcode-input-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.shortcode-prefix {
  padding: 0.65rem 0.7rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

/* Accessible Switch Control */
.switches-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.85rem;
  margin: 0.5rem 0 1.15rem;
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.95rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.switch-title {
  font-weight: 650;
  font-size: 0.92rem;
}

.switch-desc {
  color: var(--muted);
  font-size: 0.8rem;
}

input[type="checkbox"][switch] {
  accent-color: var(--brand);
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

/* Fallback tactile pill switch for browsers without native HTML switch attribute */
input[type="checkbox"][data-custom-switch] {
  appearance: none;
  width: 44px;
  height: 25px;
  border-radius: 999px;
  background: var(--muted);
  border: 2px solid transparent;
  position: relative;
  transition: background-color 0.16s ease;
}

input[type="checkbox"][data-custom-switch]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.16s ease;
}

input[type="checkbox"][data-custom-switch]:checked {
  background: var(--brand);
}

input[type="checkbox"][data-custom-switch]:checked::before {
  transform: translateX(19px);
}

input[type="checkbox"][switch]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Alerts & Buttons */
.form-alert {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 550;
  margin-bottom: 1rem;
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.form-alert[data-kind="success"] {
  border-color: var(--success);
  background: rgba(21, 128, 61, 0.12);
  color: var(--success);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-block-size: 38px;
  padding: 0.55rem 1.05rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.btn:focus-visible,
.btn-icon:focus-visible,
.copy-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-contrast);
}

.btn-secondary {
  background: var(--surface-subtle);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

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

.btn-sm {
  min-block-size: 32px;
  padding: 0.35rem 0.7rem;
  font-size: 0.83rem;
}

.btn-block {
  width: 100%;
}

/* Admin Lists */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.item-row.is-inactive {
  opacity: 0.68;
}

.item-main {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.item-title {
  font-weight: 700;
  font-size: 0.98rem;
}

.item-url {
  color: var(--brand);
  font-size: 0.85rem;
  text-decoration: none;
  word-break: break-all;
}

.item-url:hover {
  text-decoration: underline;
}

.item-meta {
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.tag {
  font-size: 0.74rem;
  font-weight: 650;
  padding: 0.14rem 0.5rem;
  border-radius: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag-accent {
  color: var(--brand);
}

.item-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon {
  appearance: none;
  min-inline-size: 32px;
  min-block-size: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

/* Accessible Copy Button & Live Status Bubble (per modern-web-guidance) */
.copy {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.copy-button {
  appearance: none;
  min-inline-size: 32px;
  min-block-size: 32px;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.copy-button[data-copied] {
  border-color: var(--success);
  color: var(--success);
}

.copy .tip {
  position: absolute;
  inset-block-end: calc(100% + 6px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  padding: 0.22rem 0.5rem;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.copy-button:is([data-copied], [data-failed]) + .tip {
  opacity: 1;
}

/* Native Modal Dialog */
.modal-dialog {
  width: min(540px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal-dialog::backdrop {
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(3px);
}

.modal-content {
  padding: 1.4rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
}
