:root {
  --bg: #05070d;
  --bg-soft: #0c1320;
  --surface: #121828;
  --surface-2: #1a2235;
  --text: #f4f7ff;
  --muted: #b9c2d8;
  --red: #8f1d2c;
  --red-bright: #c22f45;
  --blue: #194572;
  --blue-bright: #2d6cab;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Source Sans 3", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 10%, rgba(194, 47, 69, 0.24), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(45, 108, 171, 0.25), transparent 44%),
    linear-gradient(140deg, #04060c 0%, #0b1220 55%, #090f1a 100%);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(5, 8, 14, 0.8);
  border-bottom: 1px solid var(--line);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
}

.brand {
  font-family: "Bebas Neue", "Impact", sans-serif;
  letter-spacing: 1.2px;
  font-size: 1.9rem;
  color: var(--text);
}

.brand .brand-accent {
  color: var(--red-bright);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.menu-toggle span {
  width: 20px;
  height: 2px;
  background: #eaf0ff;
  border-radius: 999px;
}

.nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.nav a:hover,
.nav a.current {
  color: var(--text);
  border-color: var(--line);
  background: linear-gradient(90deg, rgba(143, 29, 44, 0.25), rgba(25, 69, 114, 0.24));
}

.hero {
  position: relative;
  overflow: hidden;
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(130deg, rgba(143, 29, 44, 0.12), rgba(25, 69, 114, 0.12));
  box-shadow: var(--shadow);
}

.hero-bg {
  position: absolute;
  inset: 0;
}

.hero-bg img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: saturate(1) contrast(1.02) brightness(0.7);
  animation: heroSlideshow 30s infinite;
}

.hero-bg img:nth-child(2) {
  animation-delay: 5s;
}

.hero-bg img:nth-child(3) {
  animation-delay: 10s;
}

.hero-bg img:nth-child(4) {
  animation-delay: 15s;
}

.hero-bg img:nth-child(5) {
  animation-delay: 20s;
}

.hero-bg img:nth-child(6) {
  animation-delay: 25s;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.hero-inner {
  position: relative;
  z-index: 2;
  padding: 52px 28px;
  display: grid;
  gap: 18px;
}

.hero-subbrand {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 2;
  font-family: "Bebas Neue", "Impact", sans-serif;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  letter-spacing: 1px;
  line-height: 1;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

.hero-subbrand-main {
  color: #ffffff;
}

.hero-subbrand-accent {
  color: var(--red-bright);
}

.kicker {
  font-family: "Bebas Neue", "Impact", sans-serif;
  letter-spacing: 1.4px;
  color: #ffd1d8;
  font-size: 1rem;
}

h1,
h2,
h3 {
  font-family: "Bebas Neue", "Impact", sans-serif;
  letter-spacing: 0.7px;
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.2rem, 8vw, 4.2rem);
  max-width: 16ch;
}

h2 {
  font-size: clamp(1.8rem, 6vw, 3rem);
}

.hero p {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.08rem;
  margin: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  border: 1px solid var(--line);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-primary {
  background: linear-gradient(100deg, var(--red-bright), var(--blue-bright));
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
}

.section {
  padding: 60px 0 10px;
}

.section-head {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  max-width: 66ch;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  box-shadow: var(--shadow);
}

.build-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--build-image);
  background-size: cover;
  background-position: center;
  opacity: 0.55;
  filter: saturate(1.08) contrast(1.06) brightness(1.04);
  transform: scale(1.05);
}

.build-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, rgba(7, 11, 20, 0.48), rgba(7, 11, 20, 0.35));
}

.build-card > * {
  position: relative;
  z-index: 1;
}

.build-card h3,
.build-card p {
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.build-layouts {
  --build-image: url("images/slot-car-pitlane-finish-straight.jpg");
}

.build-kits {
  --build-image: url("images/railway-unpainted-water-tower-build.jpg");
}

.build-3d {
  --build-image: url("images/railway-3d-printed-crane-kit.jpg");
}

.build-scenic {
  --build-image: url("images/railway-waterfall-stone-bridge.jpg");
}

.build-buildings {
  --build-image: url("images/railway-industrial-warehouse-front.jpg");
}

.build-upgrades {
  --build-image: url("images/slot-car-service-garage-overview.jpg");
}

.card h3 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.card p,
.card li {
  color: var(--muted);
  margin: 0;
}

.card ul {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.link-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.link-list a {
  color: var(--text);
  font-weight: 700;
}

.link-list a:hover {
  color: #ffd1d8;
}

.link-list span {
  display: block;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 400;
  margin-top: 2px;
}

.contact-panel {
  position: relative;
  overflow: hidden;
  min-height: 270px;
  border-color: rgba(255, 255, 255, 0.2);
}

.contact-bg {
  position: absolute;
  inset: 0;
  background: #ffffff;
}

.contact-bg img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: saturate(0.9) contrast(1) brightness(0.82);
  animation: contactSlideshow 20s infinite;
}

.contact-bg img:nth-child(2) {
  animation-delay: 5s;
}

.contact-bg img:nth-child(3) {
  animation-delay: 10s;
}

.contact-bg img:nth-child(4) {
  animation-delay: 15s;
}

.contact-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.82) 50%, rgba(255, 255, 255, 0.56));
  z-index: 1;
}

.contact-content {
  position: relative;
  z-index: 2;
}

.contact-panel h3 {
  font-size: 1.61rem;
}

.contact-content p {
  color: #273248;
  font-size: 1.15rem;
}

.contact-content h3,
.contact-content a,
.contact-content strong {
  color: #0f1728;
}

.contact-lead {
  font-size: 1.24rem;
  color: #0f1728;
  margin-bottom: 10px;
  max-width: 44ch;
}

@keyframes contactSlideshow {
  0% {
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  22% {
    opacity: 1;
  }
  30% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.process {
  counter-reset: step;
}

.process li {
  list-style: none;
  position: relative;
  padding-left: 34px;
  margin-bottom: 12px;
}

.process li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.86rem;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--red-bright), var(--blue));
  color: white;
}

.work-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.gallery-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
  margin-bottom: 12px;
  color: var(--muted);
}

.gallery-loading.is-hidden {
  display: none;
}

.gallery-loading p {
  margin: 0;
}

.gallery-toolbar {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}

.gallery-chip:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.35);
}

.gallery-chip.is-active {
  color: var(--text);
  border-color: transparent;
  background: linear-gradient(100deg, rgba(194, 47, 69, 0.95), rgba(45, 108, 171, 0.95));
}

.gallery-result-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.gallery-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffd1d8;
  animation: gallerySpin 0.9s linear infinite;
}

@keyframes gallerySpin {
  to {
    transform: rotate(360deg);
  }
}

.work-item {
  display: flex;
  flex-direction: column;
  height: 408px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.work-image {
  height: 240px;
  background: linear-gradient(135deg, #1d2331, #223551 40%, #44212a 100%);
  display: grid;
  place-items: center;
  padding: 0;
  text-align: center;
  color: #d5def3;
  font-weight: 600;
}

.work-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.work-copy {
  padding: 14px;
  min-height: 168px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  background: rgba(0, 0, 0, 0.6);
}

.work-copy h3 {
  font-size: 1.25rem;
  line-height: 1.1;
  margin: 0 0 8px;
}

.work-tag {
  align-self: start;
  margin: 0 0 12px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #f8dbe1;
  background: rgba(194, 47, 69, 0.22);
  border: 1px solid rgba(194, 47, 69, 0.4);
}

.work-copy p {
  margin: 0;
  line-height: 1.35;
  color: var(--muted);
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.work-copy p.work-tag {
  margin: 0 0 12px;
}

.work-placeholder {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.01);
  box-shadow: none;
}

.work-placeholder .work-image {
  background: linear-gradient(135deg, rgba(29, 35, 49, 0.5), rgba(34, 53, 81, 0.28));
}

.work-placeholder .work-copy {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
}

.category-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.category-strip img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.sale-grid {
  gap: 18px;
}

.sale-item {
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 2fr;
  align-items: start;
  gap: 16px;
  overflow: hidden;
}

.sale-media {
  aspect-ratio: 4 / 3;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: linear-gradient(135deg, #1d2331, #223551 40%, #44212a 100%);
  overflow: hidden;
}

.sale-media img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: cover;
  object-position: center;
}

.sale-copy {
  padding: 18px 22px 18px 18px;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.sale-copy p {
  margin: 0;
}

.sale-price {
  font-weight: 700;
  color: #ffd1d8;
  font-size: 1.2rem;
}

.sale-scale {
  font-size: 0.92rem;
  color: #d1d9ea;
}

.sale-actions {
  margin-top: 10px;
}

.footer {
  margin-top: 54px;
  border-top: 1px solid var(--line);
  background: rgba(7, 10, 17, 0.75);
}

.footer-inner {
  padding: 24px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.footer-inner p {
  margin: 0;
}

.site-tagline {
  color: #ffd1d8;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.copyright {
  flex-basis: 100%;
  order: 3;
  text-align: left;
}

.reveal {
  animation: reveal 0.6s ease both;
}

.reveal:nth-child(2) {
  animation-delay: 80ms;
}

.reveal:nth-child(3) {
  animation-delay: 130ms;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heroSlideshow {
  0% {
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  22% {
    opacity: 1;
  }
  30% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .grid-3,
  .work-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero-inner {
    padding: 42px 22px;
  }
}

@media (max-width: 640px) {
  .nav-wrap {
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(8, 14, 24, 0.95);
  }

  .nav.is-open {
    display: flex;
  }

  .nav a {
    width: 100%;
    border-radius: 10px;
    padding: 10px 12px;
  }

  .hero-inner {
    padding: 34px 18px;
  }

  .hero-subbrand {
    top: 14px;
    right: 14px;
    font-size: clamp(1.4rem, 7vw, 2rem);
  }

  .grid-2,
  .grid-3,
  .work-grid {
    grid-template-columns: 1fr;
  }

  .category-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .category-strip img {
    height: 96px;
  }

  .section {
    padding-top: 44px;
  }

  .gallery-loading {
    min-height: 62px;
    font-size: 0.95rem;
  }

  .gallery-chip {
    padding: 8px 12px;
    font-size: 0.92rem;
  }

  .work-item {
    height: 390px;
  }

  .work-image {
    height: 220px;
  }

  .sale-item {
    grid-template-columns: 1fr;
  }

  .sale-media {
    aspect-ratio: 4 / 3;
    min-height: 220px;
  }
}

/* Editor page styles scoped to avoid affecting public pages */
.editor-page .container {
  width: min(1500px, 98vw);
}

.editor-page .shell {
  padding: 24px 0 28px;
}

.editor-page h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  max-width: none;
}

.editor-page p {
  margin: 8px 0 0;
  color: var(--muted);
}

.editor-page .status {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.editor-page .status.info {
  color: #dbe6ff;
  background: rgba(45, 108, 171, 0.18);
  border-color: rgba(45, 108, 171, 0.35);
}

.editor-page .status.success {
  color: #e6fff4;
  background: rgba(47, 187, 118, 0.15);
  border-color: rgba(47, 187, 118, 0.35);
}

.editor-page .status.error {
  color: #ffe8ed;
  background: rgba(216, 79, 97, 0.15);
  border-color: rgba(216, 79, 97, 0.35);
}

.editor-page .login-wrap {
  max-width: 460px;
  margin: 6vh auto 0;
}

.editor-page .field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.editor-page label {
  font-weight: 700;
  color: #dfe8ff;
}

.editor-page input[type="text"],
.editor-page input[type="password"],
.editor-page input[type="file"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 11, 20, 0.9);
  color: #f7fbff;
  padding: 10px 12px;
  font: inherit;
}

.editor-page .actions {
  margin-top: 14px;
}

.editor-page .btn-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.editor-page .toggle-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0 16px;
}

.editor-page .toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  color: #d5def4;
  font-weight: 700;
}

.editor-page .toggle.active {
  background: linear-gradient(100deg, rgba(194, 47, 69, 0.35), rgba(45, 108, 171, 0.35));
  color: #ffffff;
}

.editor-page .editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.editor-page .editor-syntax-wrap {
  position: relative;
  height: calc(15 * 1.5em + 24px);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 11, 20, 0.9);
  overflow: hidden;
}

.editor-page .editor-rich {
  height: calc(15 * 1.5em + 24px);
  margin: 0;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  tab-size: 2;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  background: transparent;
  color: #f7fbff;
  caret-color: #f7fbff;
  outline: none;
}

.editor-page .editor-rich::selection,
.editor-page .editor-rich *::selection {
  background: rgba(134, 198, 255, 0.35);
}

.editor-page .editor-hidden-input {
  display: none;
}

.editor-page .token-key {
  color: #86c6ff;
}

.editor-page .token-string {
  color: #ffd27b;
}

.editor-page .token-number {
  color: #9bdf99;
}

.editor-page .token-bool {
  color: #f0b0ff;
}

.editor-page .token-null {
  color: #ff9ea9;
}

.editor-page .token-punc {
  color: #b6c4e2;
}

.editor-page .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.editor-page .meta {
  color: #ced8f1;
  font-size: 0.95rem;
}

@media (max-width: 980px) {
  .editor-page .editor-grid {
    grid-template-columns: 1fr;
  }

  .editor-page textarea,
  .editor-page .editor-rich,
  .editor-page .editor-syntax-wrap {
    height: calc(15 * 1.5em + 24px);
  }
}

/* Magazine page image expand/collapse */
.magazine-page .magazine-page-image {
  width: 100%;
  cursor: zoom-in;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.magazine-lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: start;
  justify-content: center;
  padding: 22px 0;
  background: rgba(3, 5, 9, 0.9);
  cursor: zoom-out;
  overflow-y: auto;
  overflow-x: hidden;
}

.magazine-lightbox.is-open {
  display: flex;
}

.magazine-lightbox-inner {
  width: min(1100px, 92vw);
  margin: 0 auto 22px;
}

.magazine-lightbox img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
}
