/* UI DESIGN PRINCIPLE: The entire UI design must align with maximal CSS Grid
 * implementation for layout and positioning. All layout and positioning decisions
 * must use CSS Grid features (grid-template, grid-area, justify-self, align-self,
 * gap, container query units, etc.) rather than absolute positioning or fixed
 * offsets. Absolute positioning is reserved for overlay elements that must escape
 * the grid flow (e.g., scroll buttons), and even then, grid alignment should be
 * preferred where possible. */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --nav-bg: #0f172a;
  --radius-sm: 6px;
  --radius: 8px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* Masthead carousel: the slides share one grid cell behind the
 * navbar and hero rows. Loop is 26s for 2 slides, 10s pause each
 * with 3s crossfades. Extra slides: lengthen the loop and stagger
 * each slide's animation-delay by one slot. */
.masthead {
  display: grid;
  grid-template-rows: 216px auto;
}

.slide {
  grid-row: 1/3;
  grid-column: 1;
  background-size: cover;
  background-position: center;
  opacity: 0;
  animation: heroFade 26s linear infinite;
}

.slide-1 {
  background-image: url("/assets/hero/slide-1.jpg");
}

.slide-2 {
  background-image: url("/assets/hero/slide-2.jpg");
  animation-delay: 13s;
}

@keyframes heroFade {
  0% {
    opacity: 0;
  }
  11.538% {
    opacity: 1;
  }
  50% {
    opacity: 1;
  }
  61.538% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
.navbar {
  grid-row: 1;
  grid-column: 1;
  z-index: 1;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2.5rem 2.5rem 0;
  height: 216px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.navbar-logo {
  height: 100%;
  width: auto;
  max-height: 216px;
  display: block;
  background: rgba(15, 23, 42, 0.5);
  padding: 0.5rem;
}

.brandrow {
  display: contents;
}

.navbar-menu {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: rgba(15, 23, 42, 0.5);
  padding: 1rem 1.25rem;
}

.navbar-menu a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
  text-align: right;
  white-space: nowrap;
}

.navbar-menu a:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.05);
}

.main {
  display: grid;
  grid-template-rows: 1fr;
  padding: 4rem 4rem 3rem;
  width: 100%;
  margin: 0 auto;
  gap: 1.25rem;
  min-height: 0;
}

.hero {
  grid-row: 2;
  grid-column: 1;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0.35rem;
  padding: 2.5rem 2.5rem 3rem;
}

.hero-brand {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  font-size: clamp(1.75rem, 4.5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: #f8fafc;
  margin: 0;
}

.tagline-block {
  background: rgba(15, 23, 42, 0.5);
  padding: 1rem 1.25rem;
  width: fit-content;
}

.tagline-block p {
  font-size: clamp(1.75rem, 4.5vw, 2.75rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: #f8fafc;
  margin: 0;
}

.tagline-block .t-sub {
  display: block;
  margin-top: 0.35em;
  margin-bottom: -0.55em;
  font-size: 1em;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  transform: scaleY(0.5);
  transform-origin: left top;
}

.hero-tagline {
  font-size: clamp(1.75rem, 4.5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: #f8fafc;
  margin: 0;
}

.family {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.9125rem;
  align-content: start;
  min-height: 0;
}

.family-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.family-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  transform: translateY(-1px);
}

.family-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
}

.family-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.family-card.card-art {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.family-card.card-art-exotalk {
  background-image: url("/assets/cards/exotalk.png");
}

.family-card.card-art-exosoul {
  background-image: url("/assets/cards/exosoul.png");
}

.family-card.card-art-conscia {
  background-image: url("/assets/cards/conscia.png");
}

.family-card.card-art-exonomy {
  background-image: url("/assets/cards/exonomy.png");
}

.family-card.card-art-exocracy {
  background-image: url("/assets/cards/exocracy.png");
}

.family-card.card-art-republet {
  background-image: url("/assets/cards/republet.png");
}

.family-card.card-art-threesteps {
  background-image: url("/assets/cards/threesteps.png");
}

.family-card.card-art-internovel {
  background-image: url("/assets/cards/internovel.png");
}

/* Flip cards: twice the size, two faces, grid-built, rem-scaled. */
.flip {
  perspective: 120rem;
  cursor: pointer;
}

.flip-box {
  display: grid;
  aspect-ratio: 1/1;
  transition: transform 0.9s ease-in-out;
  transform-style: preserve-3d;
}

.flip-box.flipped {
  transform: rotateY(180deg);
}

.face {
  grid-area: 1/1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: #dbeafe;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  display: grid;
  min-height: 0;
  min-width: 0;
}

.flip:hover .face {
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
}

.face.front {
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0;
  gap: 0;
  background: #ece9f4;
}

.face.front h3 {
  grid-row: 1;
  grid-column: 1;
  align-self: start;
  justify-self: stretch;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: linear-gradient(to right, #443377 0%, #443377 66.666%, rgba(68, 51, 119, 0) 100%);
  color: #f8fafc;
  padding: 0.75rem 0 0.75rem 2.5rem;
  font-size: 1.8rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.family > .flip:nth-child(1) .face.front h3 {
  background: linear-gradient(to right, #5f48a6 0%, #5f48a6 66.666%, rgba(95, 72, 166, 0) 100%);
}

.family > .flip:nth-child(2) .face.front h3 {
  background: linear-gradient(to right, #1e73e6 0%, #1e73e6 66.666%, rgba(30, 115, 230, 0) 100%);
}

.family > .flip:nth-child(3) .face.front h3 {
  background: linear-gradient(to right, #60a830 0%, #60a830 66.666%, rgba(96, 168, 48, 0) 100%);
}

.art {
  grid-row: 2;
  grid-column: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  min-height: 0;
  min-width: 0;
  margin: 3%;
}

.art img {
  grid-row: 1/3;
  grid-column: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  -webkit-mask-image: none;
  mask-image: none;
}

.face.front .art,
.face.front .art img,
.face.front .teaser,
.face.front h3,
.face.back *,
.face.front * {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.teaser {
  grid-row: 2;
  grid-column: 1;
  align-self: end;
  margin: 0 0 2.5rem;
  padding: 2.5rem 2.5rem 0;
  font-size: 1.35rem;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-clamp: 5;
}

.face.back {
  transform: rotateY(180deg);
  container-type: inline-size;
  position: relative;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
  background: #ecf5e6;
}

.emblem {
  grid-row: 1;
  grid-column: 1;
  max-width: 70%;
  max-height: 100%;
  justify-self: center;
  align-self: center;
  object-fit: contain;
}

.full {
  grid-row: 2;
  grid-column: 1;
  overflow-y: auto;
  scrollbar-width: none;
  min-height: 0;
  -webkit-mask-image: none;
  mask-image: none;
}

.full.fbot {
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black 78%, transparent 100%);
}

.full.ftop {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 22%, black 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 22%, black 100%);
}

.full.ftop.fbot {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 22%, black 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 22%, black 78%, transparent 100%);
}

.full::-webkit-scrollbar {
  display: none;
}

.full p {
  margin: 0;
  font-size: 1.35rem;
  color: var(--text);
  line-height: 1.6;
}

.totop {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-end: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.totop.show {
  opacity: 1;
  pointer-events: auto;
}

.totop svg {
  width: 1.1rem;
  height: 1.1rem;
}

.tobot {
  position: absolute;
  inset-block-end: 0.75rem;
  inset-inline-end: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.tobot.show {
  opacity: 1;
  pointer-events: auto;
}

.tobot svg {
  width: 1.1rem;
  height: 1.1rem;
}

.backlabel {
  grid-row: 1;
  grid-column: 1;
  justify-self: start;
  align-self: start;
  margin: 0;
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  visibility: visible;
  pointer-events: none;
}

@media (max-width: 768px) {
  .navbar {
    padding: 0 1.25rem;
  }
  .navbar-menu a {
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
  }
  .main {
    padding: 3.75rem 3rem 3rem;
    gap: 1rem;
  }
  .family {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.4625rem;
    row-gap: 2.5rem;
  }
  .tagline-block p {
    font-size: 1.6rem;
  }
  .teaser, .full p {
    font-size: 1.2rem;
  }
  .family-card {
    padding: 0.9rem;
  }
}
@media (max-width: 480px) {
  body {
    grid-template-rows: auto 1fr;
  }
  .masthead {
    grid-template-rows: auto auto;
  }
  .navbar {
    height: auto;
    padding: 4% 4% 0;
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
  .navbar-logo {
    height: auto;
    max-height: 5.156rem;
    background: none;
  }
  .brandrow {
    display: grid;
    grid-template-columns: auto 1fr;
    background: rgba(15, 23, 42, 0.5);
    background-clip: content-box;
    padding: 4%;
    width: 100%;
  }
  .navbar-menu {
    background: none;
    padding: 0;
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    justify-items: end;
    height: 100%;
    gap: 0;
  }
  .navbar-menu a {
    align-self: center;
  }
  .navbar-menu a {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
  }
  .family {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .main {
    padding-top: 2rem;
  }
  .face {
    padding: 1.25rem;
  }
  .face.front h3 {
    font-size: clamp(0.855rem, 0.72rem + 1.8vw, 0.99rem);
  }
  .backlabel {
    font-size: 1.35rem;
  }
  .full p {
    font-size: 0.9rem;
  }
  .tobot {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .tobot.show {
    opacity: 1;
    pointer-events: auto;
  }
  .hero {
    padding: 4%;
  }
  .tagline-block {
    padding: 4%;
    margin-left: 4%;
  }
  .tagline-block p {
    font-size: clamp(0.8rem, 0.7rem + 1vw, 1rem);
  }
  .tagline-block .t2 {
    display: block;
  }
  .hero h1 {
    font-size: 1.75rem;
  }
}
@media (max-height: 720px) {
  .masthead {
    grid-template-rows: 140px auto;
  }
  .navbar {
    height: 140px;
    padding: 0 2rem;
  }
  .navbar-logo {
    max-height: 140px;
  }
  .navbar-menu a {
    font-size: 0.9rem;
    padding: 0.35rem 0.75rem;
  }
  .main {
    padding: 1rem 2rem 0.75rem;
    gap: 0.75rem;
  }
  .hero {
    gap: 0.2rem;
  }
  .hero-brand {
    font-size: 0.7rem;
  }
  .hero-tagline {
    font-size: 0.85rem;
  }
  .family-card {
    padding: 0.7rem 0.8rem;
    gap: 0.25rem;
  }
  .family-card h3 {
    font-size: 0.85rem;
  }
  .family-card p {
    font-size: 0.75rem;
  }
}
/* Model Updates additions: dark appearance and wide content options,
   driven by the settings controls through data attributes. */
html[data-appearance=dark] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --nav-bg: #020617;
}

html[data-appearance=dark] body {
  background: var(--bg);
  color: var(--text);
}

html[data-appearance=dark] .family-card {
  background: var(--surface);
  border-color: var(--border);
}

html[data-appearance=dark] table {
  color: var(--text);
}

html[data-appearance=dark] th, html[data-appearance=dark] td {
  border-color: var(--border);
}

html[data-appearance=dark] th {
  background: var(--surface);
}

html[data-appearance=dark] a {
  color: var(--accent);
}

html[data-width=wide] .main {
  max-width: 1400px;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

th, td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

th {
  background: var(--surface);
}

.navbar-brand {
  font-weight: 700;
}

/* Slide images served from the main host. */
.slide-1 {
  background-image: url("https://exosystems.net/assets/hero/slide-1.jpg");
}

.slide-2 {
  background-image: url("https://exosystems.net/assets/hero/slide-2.jpg");
}
