@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&display=swap');

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
  --ink:        #eae9e3;
  --ink-2:      #7b7b8a;
  --ink-3:      #42424f;
  --bg:         #08080c;
  --bg-2:       #0d0d12;
  --bg-3:       #131318;
  --bg-hover:   #17171d;
  --line:       rgba(255,255,255,0.07);
  --line-2:     rgba(255,255,255,0.12);
  --gold:       #c49a47;
  --gold-2:     #e0b95c;
  --gold-dim:   rgba(196,154,71,0.09);
  --gold-dim2:  rgba(196,154,71,0.16);
  --discord:    #5c67de;
  --danger:     #d95050;
  --success:    #3ac88a;
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Subtle grain texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 256px;
  background-repeat: repeat;
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

/* ─── Layout Shell ───────────────────────────────────────── */
.shell {
  width: min(1100px, calc(100% - 48px));
  margin-inline: auto;
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 99;
  border-bottom: 1px solid var(--line);
  background: rgba(8,8,12,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

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

/* Diamond logo mark */
.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-mark::before,
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--gold);
  transform: rotate(45deg);
}

.brand-mark::after {
  inset: 6px;
  border-color: rgba(196,154,71,0.45);
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.01em;
  transition: color 0.18s var(--ease);
  display: flex;
  align-items: center;
  gap: 5px;
}

.nav-link:hover { color: var(--ink-2); }

.nav-link-back {
  color: var(--ink-2);
}

.nav-link-back:hover { color: var(--ink); }

/* ─── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 64px;
  align-items: center;
  padding: 88px 0 72px;
  overflow: hidden;
}

/* Concentric diamond decorations */
.hero::before,
.hero::after {
  content: '';
  position: absolute;
  right: -120px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  border: 1px solid rgba(196,154,71,0.055);
  pointer-events: none;
  z-index: 0;
}
.hero::before { width: 520px; height: 520px; }
.hero::after  { width: 360px; height: 360px; border-color: rgba(196,154,71,0.08); }

.hero-left { position: relative; z-index: 1; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.kicker-line {
  display: block;
  width: 24px;
  height: 1px;
  background: var(--gold);
  opacity: 0.6;
  flex-shrink: 0;
}

h1 {
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 800;
  line-height: 1.0;
  letter-spacing: -0.045em;
  color: var(--ink);
  margin-bottom: 22px;
}

h1 em {
  font-style: normal;
  color: var(--gold);
}

.hero-sub {
  font-size: 16px;
  color: var(--ink-2);
  line-height: 1.7;
  max-width: 480px;
  font-weight: 400;
}

/* ─── Steps Panel ────────────────────────────────────────── */
.steps-panel {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  overflow: hidden;
}

.step {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: start;
  border-bottom: 1px solid var(--line);
  transition: background 0.16s var(--ease);
}

.step:last-child { border-bottom: none; }
.step:hover { background: var(--bg-hover); }

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
  border-right: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.step-content {
  padding: 18px 20px;
}

.step-content strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}

.step-content span {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* ─── Section Header ─────────────────────────────────────── */
.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 0;
  gap: 16px;
}

.section-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.section-meta {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ─── Alliance List ──────────────────────────────────────── */
.content-section {
  padding: 0 0 100px;
}

.alliance-list {
  list-style: none;
}

.alliance-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 28px;
  align-items: center;
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s var(--ease);
  cursor: default;
  position: relative;
}

.alliance-row::before {
  content: '';
  position: absolute;
  inset: 0;
  margin-inline: -24px;
  border-radius: 2px;
  background: var(--bg-hover);
  opacity: 0;
  transition: opacity 0.15s var(--ease);
  pointer-events: none;
  z-index: 0;
}

.alliance-row:hover::before { opacity: 1; }

.alliance-row > * { position: relative; z-index: 1; }

.row-index {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.row-body { min-width: 0; }

.row-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.row-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.badge-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--success);
  padding: 2px 8px;
  border: 1px solid rgba(58,200,138,0.2);
  border-radius: 2px;
  background: rgba(58,200,138,0.06);
}

.badge-open::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.row-desc {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 600px;
}

.row-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  background: var(--bg-3);
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.row-cta:hover {
  border-color: var(--gold);
  color: var(--gold-2);
  background: var(--gold-dim);
}

.row-cta-arrow {
  font-size: 14px;
  transition: transform 0.15s var(--ease);
}

.row-cta:hover .row-cta-arrow { transform: translateX(3px); }

/* Empty state */
.empty-state {
  padding: 72px 0;
  text-align: center;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--ink-3);
}

/* Loading */
.loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 64px 0;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.loading-state::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Panel (Apply / Listing) ────────────────────────────── */
.panel {
  max-width: 680px;
  margin: 40px auto 100px;
}

.panel-head {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 36px;
}

.panel-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-kicker::before {
  content: '';
  display: block;
  width: 16px;
  height: 1px;
  background: var(--gold);
  opacity: 0.5;
}

h2 {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 14px;
}

.panel-desc {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.7;
  white-space: pre-line;
  max-width: 540px;
}

/* Discord CTA block */
.discord-cta-block {
  padding: 24px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--bg-2);
  margin-bottom: 24px;
}

.discord-cta-block p {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ─── Form ───────────────────────────────────────────────── */
.field-group {
  margin-bottom: 28px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 8px;
}

.field-label span {
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 6px;
}

textarea,
input[type="email"],
input[type="text"] {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  color: var(--ink);
  outline: none;
  resize: vertical;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
  font-size: 14px;
  line-height: 1.6;
}

textarea { min-height: 140px; }
textarea[name="description"] { min-height: 200px; }

textarea::placeholder,
input::placeholder { color: var(--ink-3); }

textarea:focus,
input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196,154,71,0.1);
  background: var(--bg-3);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 22px;
  border: none;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: opacity 0.15s var(--ease), background 0.15s var(--ease);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { opacity: 0.88; }
.btn:active { opacity: 0.75; transform: scale(0.99); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }

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

.btn-gold {
  background: var(--gold);
  color: #0a0700;
  font-weight: 800;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
}

.btn-ghost:hover {
  border-color: var(--line-2);
  color: var(--ink);
  opacity: 1;
  background: var(--bg-3);
}

.btn-arrow { font-size: 15px; }

/* ─── Notice / Alert ─────────────────────────────────────── */
.notice {
  padding: 14px 16px;
  border-radius: 3px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  background: var(--bg-2);
}

.notice-info {
  border-color: rgba(92,103,222,0.25);
  background: rgba(92,103,222,0.07);
  color: #9ca3d4;
}

.notice-success {
  border-color: rgba(58,200,138,0.25);
  background: rgba(58,200,138,0.07);
  color: #6ee7b7;
}

.notice-error {
  border-color: rgba(217,80,80,0.25);
  background: rgba(217,80,80,0.07);
  color: #fca5a5;
}

/* Form actions row */
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.form-status {
  margin-top: 16px;
}

/* Success screen */
.success-screen {
  max-width: 520px;
  margin: 60px auto 100px;
  text-align: center;
}

.success-icon {
  width: 56px;
  height: 56px;
  border: 1px solid rgba(58,200,138,0.25);
  border-radius: 4px;
  background: rgba(58,200,138,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 28px;
}

.success-screen h2 {
  font-size: 28px;
  margin-bottom: 12px;
}

.success-screen p {
  font-size: 15px;
  color: var(--ink-2);
  margin-bottom: 32px;
  line-height: 1.7;
}

/* ─── Footer ─────────────────────────────────────────────── */
footer.footer {
  border-top: 1px solid var(--line);
  padding: 24px 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

footer.footer a {
  color: var(--ink-3);
  transition: color 0.15s;
}

footer.footer a:hover { color: var(--ink-2); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 860px) {
  .shell { width: calc(100% - 32px); }

  .hero {
    grid-template-columns: 1fr;
    padding: 56px 0 44px;
    gap: 40px;
  }

  .hero::before, .hero::after { display: none; }

  .steps-panel { display: none; }

  .alliance-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 24px 0;
  }

  .row-index { display: none; }
  .row-cta { align-self: flex-start; }
}

@media (max-width: 540px) {
  .topbar-inner { gap: 12px; }
  .nav-link span.label { display: none; }
  .section-meta { display: none; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { justify-content: center; }
}

/* Functional renderer compatibility */
.alliance-grid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.alliance-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding: 24px; background: var(--surface); }
.alliance-card p { margin: 0; color: var(--muted); }
.alliance-card .card-tag { color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.alliance-card .button { grid-column: 3; grid-row: 1 / span 4; }
.guild-icon, .profile-guild-icon { width: 58px; height: 58px; object-fit: cover; border: 1px solid var(--gold); border-radius: 50%; grid-row: 1 / span 4; }
.profile-guild-icon { width: 72px; height: 72px; margin-bottom: 18px; }
.guild-icon-fallback { display: grid; place-items: center; color: var(--ink); background: var(--gold); font-weight: 800; }
.listing-meta { display: flex; gap: 8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.listing-meta strong { color: var(--text); }
.profile-meta { display: grid; gap: 12px; margin: 20px 0; }
.panel-header { margin-bottom: 24px; }
.panel-header p { color: var(--muted); }
.eyebrow { color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.field { display: block; margin-top: 24px; font-weight: 700; }
.field-help { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }
.field textarea { width: 100%; min-height: 130px; margin-top: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.button, button[type="submit"] { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border: 0; background: var(--gold); color: var(--ink); font-weight: 700; text-decoration: none; cursor: pointer; }
.button-ghost { border: 1px solid var(--line); background: transparent; color: var(--text); }
.button-secondary { background: var(--gold); color: var(--ink); }
.notice.info { border-left-color: var(--blue); }
.notice.success { border-left-color: var(--green); }
.notice.error { border-left-color: var(--red); }

@media (max-width: 700px) {
  .alliance-card { grid-template-columns: auto 1fr; }
  .alliance-card .button { grid-column: 1 / -1; grid-row: auto; }
}

.admin-panel { margin-top: 40px; }
.admin-panel h1, .panel h1 { margin: 0 0 12px; font-size: clamp(28px, 5vw, 48px); line-height: 1.05; }
.publish-toggle { display: flex; gap: 14px; align-items: flex-start; margin-top: 26px; padding: 18px; border: 1px solid var(--line); cursor: pointer; }
.publish-toggle input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--gold); }
.publish-toggle-copy { display: grid; gap: 3px; }
.publish-toggle-copy strong { color: var(--text); }
.publish-toggle-copy small { color: var(--muted); }
