/* ==========================================================================
   Kalytera Kaita — Design System
   Three-tier background system:
     1. Band (nav/hero/footer) — fixed brand navy in both themes
     2. Body — neutral surface, alternates between two shades per theme
     3. CTA (Ko-fi/support) — fixed orange, never switches with theme
   ========================================================================== */

/* ---- Base palette (theme-independent) ---- */
:root {
  --color-navy: #135370;
  --color-dark: #142329;
  --color-orange: #E77C55;
  --color-surface-light: #F5F6F7;
  --color-surface-light-dim: #F0F1F2;
  --color-surface-dark: #19282F;
  --color-surface-dark-alt: #1B2A31;
  --color-text-dark-mode: #D7DADC;
  --color-white: #FFF;
  --font-display: 'Fraunces', georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 20px;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4.5rem;
  --max-width: 1440px;
  --featured-card-max-width: 1280px;
  --transition-theme: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;

  /* Fixed CTA band — never varies with theme */
  --cta-bg: var(--color-orange);
  --cta-text: var(--color-dark); /* validated 5.69:1 on orange */
}

/* ---- Theme tokens ---- */
[data-theme="light"] {
  --band-bg: var(--color-navy);
  --band-text: var(--color-white);
  --band-text-muted: rgb(255 255 255 / 75%);
  --band-border: rgb(255 255 255 / 18%);
  --body-bg: var(--color-surface-light-dim);
  --surface-alt: var(--color-surface-light);
  --body-text: var(--color-dark);
  --body-text-muted: rgb(20 35 41 / 70%);
  --heading-color: var(--color-navy);
  --border-subtle: rgb(20 35 41 / 12%);
  --link-color: var(--color-navy);
  --link-hover: var(--color-orange);
  --card-bg: var(--color-white);
  --card-border: rgb(20 35 41 / 10%);

  /* Light stroke for navy fills on dark surfaces (contrast); invisible
     here since light-mode navy already has good contrast on its own. */
  --navy-safe-border: transparent;
}

[data-theme="dark"] {
  --band-bg: var(--color-navy);
  --band-text: var(--color-text-dark-mode);
  --band-text-muted: rgb(245 246 247 / 75%);
  --band-border: rgb(245 246 247 / 14%);
  --body-bg: var(--color-surface-dark);
  --surface-alt: var(--color-surface-dark-alt);
  --body-text: var(--color-text-dark-mode);
  --body-text-muted: rgb(245 246 247 / 70%);
  --heading-color: var(--color-text-dark-mode);
  --border-subtle: rgb(245 246 247 / 14%);
  --link-color: var(--color-text-dark-mode);
  --link-hover: var(--color-orange);
  --card-bg: rgb(245 246 247 / 6%);
  --card-border: rgb(245 246 247 / 14%);

  /* Light stroke for navy fills on dark surfaces, where navy alone
     fails contrast. */
  --navy-safe-border: var(--color-surface-light);
}

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

html {
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  background-color: var(--body-bg);
  color: var(--body-text);
  transition: var(--transition-theme);
}

main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  display: block;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---- Typography ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--heading-color);
  line-height: 1.15;
  margin: 0 0 var(--space-2);
}

h1 {
  font-size: clamp(2.25rem, 4vw, 3.5rem);
  font-weight: 600;
}

h2 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 600;
}

h3 {
  font-size: 1.375rem;
  font-weight: 600;
}

p {
  line-height: 1.65;
  margin: 0 0 var(--space-2);
  color: var(--body-text);
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: var(--transition-theme);
}

a:hover,
a:focus-visible {
  color: var(--link-hover);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Layout helpers ---- */
.section {
  padding: var(--space-4) var(--space-3);
  transition: var(--transition-theme);
}

/* Absorbs leftover vertical space in main's flex column, so the
   following section sits flush at the bottom on short pages. */
.section--fill {
  flex-grow: 1;
}

/* Alternating neutral-surface shades: separates adjacent sections without
   relying on gap size or visible borders. */
.surface-base {
  background-color: var(--body-bg);
}

.surface-alt {
  background-color: var(--surface-alt);
}

.section__inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ---- Tier 1: brand band (nav / hero / footer) ---- */
.site-band {
  background-color: var(--band-bg);
  color: var(--band-text);
  transition: var(--transition-theme);
}

.site-band h1,
.site-band h2,
.site-band h3,
.site-band p {
  color: var(--band-text);
}

/* ---- Tier 3: fixed CTA / support band ---- */
.cta-band {
  background-color: var(--cta-bg);
  color: var(--cta-text);
}

.cta-band h1,
.cta-band h2,
.cta-band h3,
.cta-band p {
  color: var(--cta-text);
}

/* Plain links on the orange band must not turn orange on hover (the
   global a:hover does), or they'd vanish against the band. :not(.btn)
   avoids overriding .btn--on-cta's own hover styling. */
.cta-band a:not(.btn):hover,
.cta-band a:not(.btn):focus-visible {
  color: var(--cta-text);
}

/* ---- Nav ---- */
.site-nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.site-nav__brand img {
  height: 90px;
  width: auto;
}

.site-nav__right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.site-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.nav-link {
  color: var(--band-text);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.25rem 0.1rem;
  border-bottom: 2px solid transparent;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--color-orange);
}

.nav-link.is-active {
  border-bottom-color: var(--color-orange);
}

.site-nav__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--band-border);
  background: transparent;
  color: var(--band-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  transition: var(--transition-theme);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--color-orange);
  color: var(--color-orange);
}

/* ---- Hero ---- */
.hero__inner {
  max-width: var(--max-width);
  margin: 0 auto;

  /* Extra left padding shifts the text+image unit right without
     changing the gap between them. */
  padding: var(--space-1) var(--space-3) var(--space-6) calc(var(--space-3) + 4rem);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: var(--space-5);
}

.hero__lede {
  font-size: 1.125rem;
  color: var(--band-text-muted);
}

.hero__image {
  display: flex;
  justify-content: center;
}

.hero__wordmark {
  width: 100%;
  max-width: 420px;
  height: auto;
  align-self: center;
  box-shadow: 0 20px 40px rgb(0 0 0 / 25%);
}

/* ---- Divider ---- */
.hero-divider {
  height: 27px;
  background-color: var(--color-orange);
}

/* ---- Footer ---- */
.site-footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
}

.site-footer__icon {
  width: 48px;
  height: 48px;
}

.site-footer__links {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

.site-footer__links a {
  color: var(--band-text);
  font-size: 0.9rem;
}

.site-footer__links a:hover,
.site-footer__links a:focus-visible {
  color: var(--color-orange);
}

.site-footer__copy {
  color: var(--band-text-muted);
  font-size: 0.8125rem;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.site-footer__copy a {
  color: inherit;
  text-decoration: underline;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition-theme), transform 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

/* Buttons on the fixed orange CTA band use the validated dark text
   color, not white or navy. */
.btn--on-cta {
  background-color: transparent;
  color: var(--cta-text);
  border-color: var(--cta-text);
}

.btn--on-cta:hover {
  background-color: var(--cta-text);
  color: var(--cta-bg);
}

/* Shared weight for emphasized inline links (e.g. "See all", "Read more"). */
.link-emphasis {
  font-weight: 600;
}

/* ---- Featured App ---- */

.featured-app__header {
  max-width: var(--featured-card-max-width);
  margin: 0 auto var(--space-3);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.section-label {
  margin: 0;
  font-size: 1.5rem;
}

.see-all {
  font-size: 0.95rem;
  white-space: nowrap;
}

.app-card {
  position: relative;
  max-width: var(--featured-card-max-width);
  margin: 0 auto;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: grid;
  grid-template-columns: minmax(110px, 140px) 1fr;
  gap: var(--space-2);
  align-items: center;
}

.app-card__identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-1);
}

.app-card__icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.app-card__name {
  margin: 0;
  font-size: 1.25rem;
}

.app-card__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding-top: var(--space-4);
}

.app-card__description {
  margin: 0;
}

/* Status pill: brand-band fill + light text; the dot, not the fill,
   carries the orange accent. */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: var(--band-bg);
  color: var(--band-text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.status-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-orange);
  flex-shrink: 0;
}

/* Pins the status pill to the card's top-right corner. */
.status-pill--corner {
  position: absolute;
  top: 20px;
  right: 20px;
}

/* ---- About Me Teaser ---- */

.about-teaser__grid {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: var(--space-4);
}

.about-teaser__photo {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--card-border);
  flex-shrink: 0;
}

/* ---- Support Band ---- */
.support-band {
  text-align: center;
}

.support-band__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.support-band__link {
  display: inline-block;
  color: var(--cta-text);
  text-decoration: underline;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.15em 0.5em;
  margin: -0.15em -0.5em;
  border-radius: var(--radius-sm);
  transition: var(--transition-theme);
}

/* Hover feedback as a highlight pill rather than a color change; text
   color already comes from the .cta-band a:not(.btn):hover rule above. */
.support-band__link:hover,
.support-band__link:focus-visible {
  background-color: rgb(20 35 41 / 12%);
  text-decoration: none;
}

/* ---- Portfolio Grid ---- */
.portfolio-grid {
  display: grid;
  margin-top: 2rem;

  /* auto-fill (not auto-fit) sizes a single card to one grid cell
     instead of stretching it to fill the row. */
  grid-template-columns: repeat(auto-fill, minmax(400px, 460px));
  justify-content: start;
  gap: var(--space-5);
}

/* Card chrome stays site-consistent; --app-* custom properties (set per
   entry in js/portfolio.js) drive each app's own brand colors, falling
   back to Kalytera's site styling when unset. */
.portfolio-card {
  --app-card-bg: var(--card-bg);
  --app-header-bg: var(--band-bg);
  --app-header-text: var(--band-text);
  --app-header-muted: var(--band-text-muted);
  --app-accent: var(--color-navy);
  --app-pill-bg: var(--app-header-bg);
  --app-pill-text: var(--app-header-text);
  --app-pill-dot: var(--color-orange);
  --app-body-text: var(--body-text);

  position: relative;
  background-color: var(--app-card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* Directional lift, not a symmetric outline — shadow falls toward the
     bottom-right, like light from the top-left. */
  box-shadow: 3px 6px 16px rgb(0 0 0 / 12%);
}

.portfolio-card--placeholder {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4);
  min-height: 220px;
}

.portfolio-card__placeholder-text {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.375rem;
  color: var(--body-text-muted);
}

.portfolio-card__header {
  background-color: var(--app-header-bg);
  color: var(--app-header-text);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.portfolio-card__icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.portfolio-card__heading {
  min-width: 0;
}

.portfolio-card__name {
  margin: 0;
  font-size: 1.25rem;
  color: var(--app-header-text);
}

.portfolio-card__tagline {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--app-header-muted);
}

.portfolio-card__slogan {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--app-header-muted);
}

.portfolio-card__body {
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) * 2);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.portfolio-card__description {
  margin: 0;
  color: var(--app-body-text);
}

/* Status pill inside a portfolio card reads from that card's own
   --app-pill-* vars instead of the site-wide defaults. */
.portfolio-card .status-pill {
  background-color: var(--app-pill-bg);
  color: var(--app-pill-text);
}

.portfolio-card .status-pill__dot {
  background-color: var(--app-pill-dot);
}

/* Bottom-right status pill placement, used on portfolio cards. */
.status-pill--corner-bottom {
  position: absolute;
  bottom: 20px;
  right: 20px;
}

.portfolio-card__link {
  align-self: flex-start;
  color: var(--app-accent);
}

/* ---- Responsive ---- */
@media (width <= 720px) {
  .site-nav__brand img {
    height: 56px;
  }

  /* Un-groups links/actions from .site-nav__right so both become direct
     flex items of .site-nav__inner, letting them reorder independently:
     brand + toggle share the top row, links wrap to their own row below. */
  .site-nav__right {
    display: contents;
  }

  .site-nav__brand {
    order: 1;
  }

  .site-nav__actions {
    order: 2;
  }

  .site-nav__links {
    order: 3;
    flex-basis: 100%;
    justify-content: center;
    gap: var(--space-2);
  }

  .site-nav__links .nav-link {
    font-size: 0.8125rem;
  }

  .site-footer__links {
    gap: var(--space-2);
  }

  .site-footer__links .nav-link {
    font-size: 0.8125rem;
  }

  .hero__inner {
    grid-template-columns: 1fr;
    text-align: center;
    padding-left: var(--space-3);
  }

  .hero__image {
    order: -1;
  }

  .about-teaser__grid {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .app-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .app-card__identity,
  .app-card__body {
    align-items: center;
  }

  .app-card__body {
    padding-top: 0;
  }

  .status-pill--corner,
  .status-pill--corner-bottom {
    position: static;
    margin-top: var(--space-2);
  }

  .portfolio-card__header {
    flex-wrap: wrap;
  }

  .portfolio-card__body {
    padding-bottom: var(--space-4);
  }

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