* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --background: #020617;
  --panel: rgba(6, 19, 34, 0.95);
  --panel-hover: rgba(10, 35, 59, 0.98);
  --border: rgba(111, 158, 197, 0.38);
  --text: #f8fafc;
  --muted: #c4ceda;
  --accent: #37baff;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 3%, rgba(0, 135, 228, 0.14), transparent 35rem),
    linear-gradient(180deg, #050d18 0%, #020617 58%, #01040a 100%);
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.56;
  background-image:
    radial-gradient(circle at 10% 15%, rgba(255,255,255,.8) 0 1px, transparent 1.3px),
    radial-gradient(circle at 28% 72%, rgba(55,186,255,.72) 0 1px, transparent 1.4px),
    radial-gradient(circle at 62% 18%, rgba(255,255,255,.52) 0 1px, transparent 1.2px),
    radial-gradient(circle at 84% 62%, rgba(255,188,96,.45) 0 1px, transparent 1.2px);
  background-size: 180px 180px, 260px 260px, 320px 320px, 420px 420px;
}

.site-header,
.page-shell,
.site-footer {
  width: min(92rem, calc(100% - 2rem));
  margin: 0 auto;
}

.system-bar {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(111, 158, 197, 0.18);
  font-size: 0.78rem;
}

.system-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #35e57a;
  box-shadow: 0 0 6px #35e57a, 0 0 14px rgba(53, 229, 122, 0.72);
}

.system-label {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-divider {
  width: 1px;
  height: 18px;
  background: rgba(196, 206, 218, 0.34);
}

.system-state {
  color: #35e57a;
}

.hero {
  text-align: center;
  padding-top: clamp(1.7rem, 4vw, 3.5rem);
}

.brand-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.48em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 1rem auto 0;
  max-width: 72rem;
  font-size: clamp(2.2rem, 5.4vw, 4.8rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.hero-intro {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.hero-art {
  width: min(1180px, 96vw);
  margin: 0.8rem auto 0;
}

.hero-art img {
  width: 100%;
  display: block;
  border-radius: 0.45rem;
}

.page-shell {
  margin-top: -0.4rem;
  padding-bottom: 3rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.project-card {
  position: relative;
  min-height: 13.8rem;
  display: flex;
  flex-direction: column;
  padding: 1.22rem;
  color: inherit;
  text-decoration: none;
  background: linear-gradient(145deg, rgba(7, 24, 42, 0.96), rgba(3, 13, 24, 0.98));
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.project-card:hover,
.project-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--accent);
  background: var(--panel-hover);
  outline: none;
}

.project-number {
  margin-bottom: 0.9rem;
  color: #53baff;
  font-size: 1.42rem;
  line-height: 1;
}

.project-card h2 {
  margin: 0;
  max-width: 82%;
  font-size: 1.18rem;
  line-height: 1.22;
}

.project-card p {
  margin: 0.75rem 0 1.1rem;
  color: var(--muted);
  line-height: 1.48;
}

.open-label {
  margin-top: auto;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(111, 158, 197, 0.18);
  color: var(--accent);
  font-weight: 800;
}

.status-beacon {
  position: absolute;
  top: 1.05rem;
  right: 1.05rem;
  width: 1.1rem;
  height: 1.1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  pointer-events: none;
}

.status-beacon::before,
.status-beacon::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.55);
  animation: beaconPulse 2.4s ease-out infinite;
}

.status-beacon::after {
  animation-delay: 1.2s;
}

.status-core {
  position: relative;
  z-index: 2;
  width: 0.54rem;
  height: 0.54rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0.34rem currentColor, 0 0 0.78rem currentColor, 0 0 1.2rem currentColor;
  animation: corePulse 1.8s ease-in-out infinite;
}

.status-green { color: #35e57a; }
.status-yellow { color: #ffbd00; }
.status-red { color: #ff3344; }

.capability-strip {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid rgba(111, 158, 197, 0.42);
  border-radius: 0.75rem;
  background: linear-gradient(180deg, rgba(7, 23, 40, 0.96), rgba(3, 13, 24, 0.98));
  overflow: hidden;
}

.capability {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
}

.capability + .capability {
  border-left: 1px solid rgba(111, 158, 197, 0.24);
}

.capability svg {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.capability h3 {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.capability p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.site-footer {
  padding: 2rem 0 calc(1.8rem + env(safe-area-inset-bottom));
  color: #7f8d9d;
  text-align: center;
}

.footer-wordmark {
  width: min(650px, 88vw);
  display: block;
  margin: 0 auto 0.5rem;
}

.site-footer p {
  margin: 0;
  font-size: 0.8rem;
}

@keyframes beaconPulse {
  0% { opacity: 0; transform: scale(0.55); }
  20% { opacity: 0.82; }
  100% { opacity: 0; transform: scale(1.9); }
}

@keyframes corePulse {
  0%, 100% { opacity: 0.65; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1.12); }
}

@media (max-width: 1050px) {
  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .capability-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .capability + .capability {
    border-left: 0;
    border-top: 1px solid rgba(111, 158, 197, 0.22);
  }

  .capability:nth-child(even) {
    border-left: 1px solid rgba(111, 158, 197, 0.22);
  }
}

@media (max-width: 760px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-kicker {
    letter-spacing: 0.3em;
  }
}

@media (max-width: 540px) {
  .site-header,
  .page-shell,
  .site-footer {
    width: min(100% - 1rem, 92rem);
  }

  .system-bar {
    font-size: 0.7rem;
    gap: 0.5rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .project-card {
    min-height: 12.4rem;
  }

  .capability-strip {
    grid-template-columns: 1fr;
  }

  .capability + .capability,
  .capability:nth-child(even) {
    border-left: 0;
    border-top: 1px solid rgba(111, 158, 197, 0.22);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }

  .status-beacon::before,
  .status-beacon::after,
  .status-core {
    animation: none !important;
  }
}

/* =========================================================
   v3.2 iPad / Safari responsive corrections
   ========================================================= */

/* Prevent Safari grid children from forcing the page wider than the viewport. */
.project-grid,
.capability-strip,
.project-card,
.capability,
.capability > div {
  min-width: 0;
}

/* Keep the hero fully inside the iPad viewport. */
.hero-art {
  max-width: 100%;
  overflow: hidden;
}

.hero-art img {
  height: auto;
  object-fit: contain;
}

/* Ensure status indicators remain above card backgrounds in Safari. */
.project-card {
  isolation: isolate;
  overflow: visible;
}

.project-card::before,
.project-card::after {
  z-index: 0;
}

.project-card > :not(.status-beacon) {
  position: relative;
  z-index: 1;
}

.status-beacon {
  z-index: 5;
  display: -webkit-grid;
  display: grid;
  visibility: visible;
  opacity: 1;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.status-beacon::before,
.status-beacon::after,
.status-core {
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Dedicated iPad portrait and landscape layout. */
@media screen and (min-width: 768px) and (max-width: 1180px) {
  .site-header,
  .page-shell,
  .site-footer {
    width: min(100% - 2rem, 72rem);
  }

  .hero {
    padding-top: 1.8rem;
  }

  .brand-kicker {
    font-size: 0.86rem;
    letter-spacing: 0.34em;
  }

  .hero h1 {
    max-width: 58rem;
    font-size: clamp(2.25rem, 5.2vw, 3.75rem);
  }

  .hero-intro {
    font-size: 1.05rem;
  }

  .hero-art {
    width: 100%;
    margin-top: 0.7rem;
  }

  /* Two columns are more reliable than three on iPad Safari. */
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
  }

  .project-card {
    min-height: 13rem;
    padding: 1.2rem;
    overflow: visible;
  }

  .status-beacon {
    top: 1rem;
    right: 1rem;
    width: 1.2rem;
    height: 1.2rem;
  }

  .status-core {
    width: 0.58rem;
    height: 0.58rem;
  }

  /* Render the five capabilities as a stable 2-column grid.
     The final item spans the full width. */
  .capability-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .capability {
    min-height: 5.6rem;
    border-top: 1px solid rgba(111, 158, 197, 0.22);
    border-left: 0 !important;
  }

  .capability:nth-child(-n+2) {
    border-top: 0;
  }

  .capability:nth-child(even) {
    border-left: 1px solid rgba(111, 158, 197, 0.22) !important;
  }

  .capability:last-child {
    grid-column: 1 / -1;
    justify-content: center;
    border-left: 0 !important;
  }

  .footer-wordmark {
    width: min(620px, 84vw);
  }
}

/* iPad portrait refinements. */
@media screen and (min-width: 768px) and (max-width: 900px) and (orientation: portrait) {
  .system-bar {
    padding-inline: 0.25rem;
  }

  .hero h1 {
    font-size: clamp(2.2rem, 6vw, 3.3rem);
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* iPad landscape refinements. */
@media screen and (min-width: 901px) and (max-width: 1180px) and (orientation: landscape) {
  .site-header,
  .page-shell,
  .site-footer {
    width: min(100% - 2.5rem, 76rem);
  }

  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .project-card {
    min-height: 13.4rem;
  }

  .capability-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
  }

  .capability,
  .capability:nth-child(even),
  .capability:last-child {
    grid-column: auto;
    min-height: auto;
    border-top: 0;
    border-left: 1px solid rgba(111, 158, 197, 0.24) !important;
    justify-content: flex-start;
  }

  .capability:first-child {
    border-left: 0 !important;
  }

  .capability svg {
    width: 36px;
    height: 36px;
  }

  .capability {
    gap: 0.65rem;
    padding: 0.85rem 0.7rem;
  }

  .capability h3 {
    font-size: 0.7rem;
  }

  .capability p {
    font-size: 0.68rem;
  }
}

/* Safari-specific rendering support. */
@supports (-webkit-touch-callout: none) {
  .status-beacon::before,
  .status-beacon::after {
    -webkit-animation-name: beaconPulse;
    -webkit-animation-duration: 2.4s;
    -webkit-animation-timing-function: ease-out;
    -webkit-animation-iteration-count: infinite;
  }

  .status-beacon::after {
    -webkit-animation-delay: 1.2s;
  }

  .status-core {
    -webkit-animation-name: corePulse;
    -webkit-animation-duration: 1.8s;
    -webkit-animation-timing-function: ease-in-out;
    -webkit-animation-iteration-count: infinite;
  }
}

/* =========================================================
   v3.3 Chrome / Chromium tablet corrections
   ========================================================= */

/* Avoid fractional-width and transformed-grid rendering bugs. */
.project-grid,
.capability-strip {
  width: 100%;
  max-width: 100%;
  transform: none;
  contain: layout style;
}

.project-card,
.capability {
  min-width: 0;
  max-width: 100%;
}

/* Status beacon fallback remains visible even if animation is throttled. */
.status-beacon {
  display: grid !important;
  place-items: center;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: visible;
  contain: none;
}

.status-core {
  display: block;
  opacity: 1;
  transform: none;
}

/* Chromium can drop pseudo-elements during accelerated scrolling.
   Give each beacon a persistent outer halo independent of animation. */
.status-beacon {
  box-shadow:
    0 0 0 1px currentColor,
    0 0 8px color-mix(in srgb, currentColor 70%, transparent),
    0 0 16px color-mix(in srgb, currentColor 40%, transparent);
}

/* Fallback for browsers without color-mix(). */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .status-green {
    box-shadow: 0 0 0 1px #35e57a, 0 0 8px rgba(53,229,122,.72);
  }

  .status-yellow {
    box-shadow: 0 0 0 1px #ffbd00, 0 0 8px rgba(255,189,0,.72);
  }

  .status-red {
    box-shadow: 0 0 0 1px #ff3344, 0 0 8px rgba(255,51,68,.72);
  }
}

/* Chrome tablet portrait */
@media screen and (min-width: 768px) and (max-width: 900px) {
  .site-header,
  .page-shell,
  .site-footer {
    width: calc(100% - 1.5rem);
    max-width: 100%;
  }

  .hero-art {
    width: 100%;
    max-width: 100%;
  }

  .hero-art img {
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  .project-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .9rem;
  }

  .capability-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .capability {
    min-height: 5.5rem;
    border-top: 1px solid rgba(111,158,197,.22);
    border-left: 0 !important;
  }

  .capability:nth-child(-n+2) {
    border-top: 0;
  }

  .capability:nth-child(even) {
    border-left: 1px solid rgba(111,158,197,.22) !important;
  }

  .capability:last-child {
    grid-column: 1 / -1;
    justify-content: center;
    border-left: 0 !important;
  }
}

/* Chrome tablet landscape */
@media screen and (min-width: 901px) and (max-width: 1180px) {
  .site-header,
  .page-shell,
  .site-footer {
    width: calc(100% - 2rem);
    max-width: 100%;
  }

  .hero-art {
    width: 100%;
    max-width: 100%;
  }

  .project-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .9rem;
  }

  .capability-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
  }

  .capability,
  .capability:nth-child(even),
  .capability:last-child {
    grid-column: auto;
    min-height: auto;
    border-top: 0;
    border-left: 1px solid rgba(111,158,197,.24) !important;
    justify-content: flex-start;
  }

  .capability:first-child {
    border-left: 0 !important;
  }

  .capability {
    gap: .6rem;
    padding: .8rem .65rem;
  }

  .capability svg {
    width: 34px;
    height: 34px;
  }

  .capability h3 {
    font-size: .68rem;
  }

  .capability p {
    font-size: .66rem;
  }
}

/* Prevent Chrome's tap highlight and text autosizing from changing layout. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.project-card,
.capability,
.hero-art {
  -webkit-tap-highlight-color: transparent;
}

/* =========================================================
   v3.4 iPhone status-beacon positioning correction
   ========================================================= */

/* Explicitly preserve absolute positioning after Safari stacking rules. */
.project-card > .status-beacon,
.status-beacon {
  position: absolute !important;
  inset: auto 1.05rem auto auto !important;
  top: 1.05rem !important;
  right: 1.05rem !important;
  left: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  z-index: 10 !important;
  flex: 0 0 auto;
  align-self: auto;
  justify-self: auto;
}

/* iPhone portrait and landscape, including all iOS browsers (WebKit). */
@media screen and (max-width: 767px) {
  .project-card {
    position: relative !important;
    overflow: visible;
  }

  .project-card > .status-beacon {
    position: absolute !important;
    top: 1rem !important;
    right: 1rem !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  .project-card h2 {
    padding-right: 2.25rem;
  }
}

/* Narrow iPhone portrait. */
@media screen and (max-width: 430px) and (orientation: portrait) {
  .project-card > .status-beacon {
    top: .95rem !important;
    right: .95rem !important;
  }
}

/* iPhone landscape. */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .project-card > .status-beacon {
    top: .9rem !important;
    right: .9rem !important;
  }
}
