/* ================================
   SPACE.CRAFT.ED — Global Styles
   ================================ */

:root {
  --brand: #6fe3ff;           /* cyan glow */
  --brand-2: #b893ff;         /* lilac accent */
  --txt: #e9f7ff;             /* light text */
  --muted: #a3b6c6;
  --bg: #05060a;              /* deep space */
  --card: #0c1016cc;          /* translucent panels */
  --stroke: #1a2430;
  --focus: #ffd166;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: "Rajdhani", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--txt);
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* ================================
   Global Elements
   ================================ */

.glow {
  text-shadow: 0 0 .4rem var(--brand), 0 0 1.2rem var(--brand-2);
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ================================
   Header / Navigation
   ================================ */

header.page-header {
  position: relative;
  width: 100%;
  height: 280px;
  background: url("assets/starsheader.png") center top / cover no-repeat;
  border-bottom: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin: 0;
  padding-bottom: 0.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--txt);
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 0 .8rem var(--brand));
}

.wordmark {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  letter-spacing: .02em;
}

/* ================================
   Navigation Menu
   ================================ */

nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav a {
  text-decoration: none;
  color: var(--txt);
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: background .2s, border-color .2s, box-shadow .2s;
}

nav a:hover {
  background: #0e1520;
  border-color: #203149;
}

nav a.active {
  background: linear-gradient(90deg, #0b1422, #121a28);
  border-color: #1a2638;
  box-shadow: inset 0 0 0 1px #203149, 0 0 .6rem rgba(111,227,255,.35);
}

/* ================================
   Main Content
   ================================ */

main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.panel h1, .panel h2 {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  letter-spacing: .02em;
}

/* ================================
   Card Links / Grids
   ================================ */

.grid-links {
  display: grid;
  grid-template-columns: repeat(1, minmax(0,1fr));
  gap: .75rem;
  margin-top: .75rem;
}
@media (min-width: 640px) {
  .grid-links {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}
@media (min-width: 900px) {
  .grid-links {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }
}

.card-link {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  padding: .9rem;
  border-radius: 14px;
  background: rgba(12,16,22,.6);
  border: 1px solid #101825;
  text-decoration: none;
  color: var(--txt);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card-link:hover {
  transform: translateY(-2px);
  border-color: #203149;
  box-shadow: 0 8px 20px rgba(13,22,33,.5);
}
.card-link .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: .35rem;
  box-shadow: 0 0 .6rem var(--brand);
}
.card-link h3 {
  margin: 0;
  font-family: "Rajdhani";
  font-weight: 700;
  letter-spacing: .04em;
}
.card-link p {
  margin: .15rem 0 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
}

/* ================================
   Footer
   ================================ */

footer {
  text-align: center;
  margin: 3rem 0;
  color: var(--muted);
}
footer a {
  color: var(--brand);
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}
footer img {
  height: 28px;
  vertical-align: middle;
  margin-right: .5rem;
  filter: drop-shadow(0 0 .5rem rgba(111,227,255,.4));
}

/* ================================
   Accessibility / Misc
   ================================ */

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

canvas#starfield {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
}

/* ================================
   SPACE.CRAFT.ED — Logged-in app layer
   ================================ */

body.logged-in {
  --bg: #061426;
  background:
    radial-gradient(circle at 20% 10%, rgba(111,227,255,.10), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(184,147,255,.12), transparent 28%),
    linear-gradient(180deg, #05060a 0%, #061426 44%, #081a2f 100%);
}

.compact-header {
  height: 150px;
  background:
    linear-gradient(180deg, rgba(5,6,10,.3), rgba(5,6,10,.92)),
    url("assets/starsheader.png") center top / cover no-repeat;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.lede {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.button-primary,
button.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(111,227,255,.5);
  border-radius: 999px;
  background: linear-gradient(90deg, #6fe3ff, #b893ff);
  color: #03111f;
  padding: .7rem 1rem;
  font-weight: 800;
  letter-spacing: .03em;
  cursor: pointer;
  box-shadow: 0 0 1rem rgba(111,227,255,.25);
}

.button-primary:hover {
  text-decoration: none;
  box-shadow: 0 0 1.4rem rgba(111,227,255,.42);
}

.flash-list {
  display: grid;
  gap: .5rem;
  margin: 1rem 0;
}

.flash-card {
  border: 1px solid rgba(255,209,102,.35);
  background: rgba(255,209,102,.08);
  border-radius: 12px;
  padding: .7rem .9rem;
  color: var(--txt);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.profile-card {
  display: flex;
  gap: 1rem;
  border: 1px solid #101825;
  border-radius: 16px;
  background: rgba(12,16,22,.62);
  padding: 1rem;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(111,227,255,.35);
  background: #07111e;
}

.pixel-placeholder {
  background:
    linear-gradient(90deg, rgba(111,227,255,.22) 1px, transparent 1px),
    linear-gradient(rgba(111,227,255,.22) 1px, transparent 1px),
    #07111e;
  background-size: 9px 9px;
}

.profile-main h2 {
  margin: 0 0 .25rem;
  font-family: "Orbitron", sans-serif;
  font-size: 1.05rem;
}

.meta-line {
  margin: 0 0 .35rem;
  color: var(--muted);
}

.atmospheric-pill {
  display: inline-block;
  margin: .15rem 0 .5rem;
  padding: .22rem .55rem;
  border-radius: 999px;
  border: 1px solid rgba(111,227,255,.35);
  background: rgba(111,227,255,.08);
  color: var(--brand);
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.form-panel {
  max-width: 760px;
}

.space-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.space-form label {
  display: grid;
  gap: .35rem;
  font-weight: 700;
  color: var(--txt);
}

.space-form input,
.space-form select,
.space-form textarea {
  width: 100%;
  border: 1px solid #203149;
  border-radius: 12px;
  background: rgba(2,6,23,.86);
  color: var(--txt);
  padding: .75rem .85rem;
  font: inherit;
}

.space-form textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

/* ================================
   SPACE.CRAFT.ED — App / Logged-in Theme
   ================================ */

body.logged-in {
  background:
    radial-gradient(circle at 20% 10%, rgba(111,227,255,.13), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(184,147,255,.12), transparent 28%),
    linear-gradient(180deg, #05060a 0%, #071426 45%, #081a30 100%);
}

.compact-header {
  height: 150px !important;
  background: linear-gradient(180deg, rgba(5,6,10,.9), rgba(7,20,38,.85)), url("assets/starsheader.png") center top / cover no-repeat !important;
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.lede, .muted {
  color: var(--muted);
  line-height: 1.5;
}

.button-primary, .button-secondary, button.button-primary, button.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border-radius: 999px;
  padding: .7rem 1rem;
  font-weight: 700;
  letter-spacing: .03em;
  cursor: pointer;
  text-decoration: none;
}

.button-primary {
  border: 1px solid rgba(111,227,255,.65);
  background: linear-gradient(90deg, rgba(111,227,255,.95), rgba(184,147,255,.9));
  color: #02101f;
  box-shadow: 0 0 1rem rgba(111,227,255,.22);
}

.button-secondary {
  border: 1px solid #26364c;
  background: rgba(12,16,22,.78);
  color: var(--txt);
}

.flash-list { margin: 1rem 0; display: grid; gap: .5rem; }
.flash-card {
  border: 1px solid rgba(255,209,102,.35);
  background: rgba(255,209,102,.08);
  color: var(--txt);
  border-radius: 12px;
  padding: .75rem 1rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}

.profile-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #172235;
  border-radius: 16px;
  background: rgba(12,16,22,.62);
}

.profile-avatar-wrap { flex: 0 0 auto; }
.profile-avatar, .pixel-placeholder, .profile-pixel-icon {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  border: 1px solid #26364c;
  background: rgba(255,255,255,.04);
}

.profile-pixel-icon {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  overflow: hidden;
  image-rendering: pixelated;
}

.profile-pixel-icon span { display: block; }

.pixel-placeholder {
  background:
    linear-gradient(45deg, rgba(111,227,255,.18) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(184,147,255,.18) 25%, transparent 25%),
    rgba(255,255,255,.04);
  background-size: 12px 12px;
}

.profile-main h2 { margin: 0 0 .2rem; }
.meta-line { margin: .1rem 0 .4rem; color: var(--muted); }
.atmospheric-pill {
  display: inline-flex;
  border: 1px solid rgba(111,227,255,.35);
  background: rgba(111,227,255,.08);
  color: var(--brand);
  border-radius: 999px;
  padding: .2rem .65rem;
  margin: .2rem 0 .5rem;
  font-weight: 700;
}
.profile-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .5rem; }

.space-form { display: grid; gap: 1rem; }
.space-form label { display: grid; gap: .35rem; font-weight: 700; }
.space-form input, .space-form select, .space-form textarea {
  width: 100%;
  border: 1px solid #26364c;
  border-radius: 12px;
  padding: .75rem .85rem;
  background: rgba(2,8,18,.72);
  color: var(--txt);
  font: inherit;
}
.form-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

/* ================================
   SPACE.CRAFT.ED — 8x8 Avatar Designer
   ================================ */

.avatar-popup-page {
  min-height: 100%;
}

.avatar-popup-shell {
  max-width: 980px;
  margin: 1rem auto;
}

.avatar-designer-panel {
  border-color: rgba(111,227,255,.24);
}

.avatar-workbench {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.pixel-editor-large {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(80vw, 420px);
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(111,227,255,.45);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,.04);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), 0 0 1.4rem rgba(111,227,255,.16);
}

.pixel-cell-large {
  border: 1px solid rgba(255,255,255,.08);
  min-width: 0;
  min-height: 0;
  cursor: crosshair;
}
.pixel-cell-large:hover {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.colour-palette-large {
  display: grid;
  grid-template-columns: repeat(8, 34px);
  gap: .45rem;
  margin: .6rem 0 1rem;
}

.colour-swatch-large {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.18);
  cursor: pointer;
}
.colour-swatch-large.selected {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.eraser-swatch {
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.06), rgba(255,255,255,.06) 4px, rgba(255,255,255,.18) 4px, rgba(255,255,255,.18) 8px);
  color: var(--txt);
  font-size: 1.2rem;
  font-weight: 900;
}

.avatar-preview-large {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 128px;
  height: 128px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #26364c;
  background: rgba(255,255,255,.04);
  image-rendering: pixelated;
}
.preview-pixel { display: block; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.avatar-side-panel h2 { margin: .2rem 0 .4rem; }

.astro-pi-card {
  margin-top: 1.2rem;
  border: 1px solid rgba(255,209,102,.35);
  border-radius: 16px;
  background: rgba(255,209,102,.08);
  padding: 1rem;
}
.astro-pi-card h3 { margin-top: 0; }
.center-panel { text-align: center; }

@media (max-width: 760px) {
  .avatar-workbench { grid-template-columns: 1fr; }
  .colour-palette-large { grid-template-columns: repeat(8, 1fr); }
}
.avatar-inline-card {
  border: 1px solid rgba(111,227,255,.24);
  border-radius: 14px;
  padding: 1rem;
  background: rgba(111,227,255,.06);
}
.avatar-inline-card p { margin: 0 0 .5rem; }


.avatar-grid,
#avatar-grid,
.pixel-grid,
#pixel-grid,
.icon-grid,
#icon-grid {
  display: grid !important;
  grid-template-columns: repeat(8, 28px) !important;
  grid-template-rows: repeat(8, 28px) !important;
  gap: 4px !important;
  width: max-content !important;
  max-width: none !important;
}

.avatar-grid button,
#avatar-grid button,
.pixel-grid button,
#pixel-grid button,
.icon-grid button,
#icon-grid button,
.avatar-cell,
.pixel-cell,
.icon-cell {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  border-radius: 6px !important;
  padding: 0 !important;
}
