/* ==========================================================================
   PsyKey shared layout
   Loaded after each page's own stylesheet. Holds the design tokens, the
   responsive header / navigation, shared buttons and the footer so every
   page behaves the same on phones, tablets and desktops.
   ========================================================================== */

:root {
  --bg: #202020;
  --surface: #232222e6;
  --surface-2: #14141cf2;
  --surface-3: #1b1b24;
  --line: #ffffff14;
  --line-strong: #ffffff2d;
  --text: #c7c7e6;
  --text-strong: #ececfb;
  --muted: #9a9ab8;
  --accent: #7f5af0;
  --accent-soft: #7f5af033;
  --primary: #04aa6d;
  --primary-hover: #45a049;
  --ennea: #3fb3b5;
  --mbti: #ee8f4a;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px #00000066;
  --focus: 0 0 0 3px #0b0b10, 0 0 0 5px #b9a6ff;
  --gutter: clamp(1rem, 4vw, 1.5rem);
  --header-h: 90px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100000000;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--text-strong);
  color: #111;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Header ---------- */

/* The page stylesheets make every <header> sticky with a blurred backdrop.
   Only the site header should behave that way; content headers (result and
   variant heroes) stay in the normal flow. */
header:not(.site-header) {
  position: relative;
  top: auto;
  z-index: auto;
}

header:not(.site-header)::before {
  content: none;
}

.site-header .top-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: var(--header-h);
  gap: 1rem;
}

.site-header .brand {
  gap: 0.25rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.site-header .logo {
  width: 72px;
  height: 72px;
}

.site-header .site-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.site-header .main-nav {
  align-items: center;
  margin-left: auto;
  gap: 0.25rem;
}

.site-header .main-nav > a,
.site-header .dropdown-head > a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.85rem;
  border-radius: 999px;
  font-size: 0.92rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.site-header .main-nav > a:hover,
.site-header .dropdown-head > a:hover {
  background: #ffffff10;
  color: var(--text-strong);
}

.site-header .main-nav > a[aria-current="page"],
.site-header .dropdown-head > a[aria-current="page"] {
  color: var(--text-strong);
  background: #ffffff14;
}

.site-header .ennea-pill[aria-current="page"] {
  box-shadow: inset 0 0 0 2px #ffffffd9;
}

.site-header .dropdown-head {
  display: flex;
  align-items: center;
}

.site-header .dropdown-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 44px;
  margin-left: -0.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.site-header .dropdown-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.site-header .dropdown-item.is-open .dropdown-toggle svg {
  transform: rotate(180deg);
}

/* Desktop dropdown: opens on hover, keyboard focus or toggle click */
.site-header .ennea-menu {
  top: calc(100% + 0.25rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 0;
  width: min(560px, calc(100vw - 2rem));
  box-shadow: 0 24px 60px #000000b3;
}

.site-header .ennea-menu::before {
  /* hover bridge so the menu does not close while the pointer travels */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -0.6rem;
  height: 0.6rem;
}

.site-header .dropdown-item:hover .ennea-menu,
.site-header .dropdown-item:focus-within .ennea-menu,
.site-header .dropdown-item.is-open .ennea-menu {
  display: block;
}

.site-header .dropdown-item.is-closed .ennea-menu {
  display: none;
}

.site-header .ennea-types {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.site-header .ennea-pill {
  min-width: 0;
  min-height: 52px;
  text-transform: none;
  letter-spacing: 0;
}

.site-header .ennea-pill .ennea-name {
  font-size: 0.95rem;
}

.site-header .ennea-pill .ennea-code {
  font-size: 0.78rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.site-header .ennea-all {
  display: inline-block;
  text-transform: none;
  letter-spacing: 0.02em;
  margin-top: 1.25rem;
  color: var(--text-strong);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.04em;
}

.site-header .ennea-all:hover {
  text-decoration: underline;
}

.site-header .ennea-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #ffffff0a;
  color: var(--text-strong);
  cursor: pointer;
  place-items: center;
}

.nav-toggle-bars {
  position: relative;
  width: 20px;
  height: 14px;
}

.nav-toggle-bars span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease, top 0.2s ease;
}

.nav-toggle-bars span:nth-child(1) { top: 0; }
.nav-toggle-bars span:nth-child(2) { top: 6px; }
.nav-toggle-bars span:nth-child(3) { top: 12px; }

.nav-open .nav-toggle-bars span:nth-child(1) { top: 6px; transform: rotate(45deg); }
.nav-open .nav-toggle-bars span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle-bars span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

/* ---------- Mobile navigation ---------- */

@media (max-width: 1000px) {
  :root {
    --header-h: 64px;
  }

  .site-header .logo {
    width: 52px;
    height: 52px;
  }

  .site-header .site-title {
    font-size: 1.2rem;
  }

  .nav-toggle {
    display: inline-grid;
  }

  .site-header .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.75rem var(--gutter) 1.25rem;
    background: #17171f;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 30px 60px #000000b3;
  }

  .nav-open .site-header .main-nav {
    display: flex;
  }

  .site-header .main-nav > a,
  .site-header .dropdown-head > a {
    min-height: 48px;
    padding: 0 1rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
  }

  .site-header .demo-dropdown > li {
    display: block;
  }

  .site-header .dropdown-head {
    justify-content: space-between;
  }

  .site-header .dropdown-head > a {
    flex: 1;
  }

  .site-header .dropdown-toggle {
    width: 48px;
    height: 48px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
  }

  /* In the drawer the Enneagram menu is an accordion, not a floating panel */
  .site-header .ennea-menu,
  .site-header .dropdown-item:hover .ennea-menu,
  .site-header .dropdown-item:focus-within .ennea-menu {
    position: static;
    transform: none;
    width: auto;
    display: none;
    margin: 0.25rem 0 0.5rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: none;
    background: #ffffff08;
  }

  .site-header .dropdown-item.is-open .ennea-menu {
    display: block;
  }

  .site-header .ennea-menu::before {
    display: none;
  }

  .site-header .ennea-group + .ennea-group {
    margin-top: 1rem;
  }

  .site-header .ennea-types {
    gap: 0.5rem;
  }

  .site-header .ennea-pill {
    padding: 0.5rem 0.4rem;
    box-shadow: none;
  }
}

@media (max-width: 380px) {
  .site-header .site-title {
    font-size: 1.05rem;
  }

  .site-header .ennea-pill .ennea-code {
    font-size: 0.7rem;
  }
}

/* ---------- Shared buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-hover);
}

.button-ghost {
  background: transparent;
  color: var(--text-strong);
  border-color: var(--line-strong);
}

.button-ghost:hover {
  background: #ffffff10;
}

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ---------- Footer ---------- */

footer {
  margin-top: 3rem;
}

/* ---------- Responsive fixes for existing page styles ---------- */

@media (max-width: 900px) {
  main {
    padding-left: var(--gutter);
    padding-right: var(--gutter);
  }
}

@media (max-width: 600px) {
  .exp,
  .ana,
  .start,
  .gelişme,
  .ilişki,
  .gelişim,
  .son,
  .container {
    padding: 1.4rem 1.1rem 1.6rem;
    border-radius: var(--radius-md);
  }

  .exp h1,
  .ana h1,
  .start h1,
  .gelişme h1,
  .ilişki h1,
  .gelişim h1,
  .son h1 {
    font-size: 1.45rem;
    line-height: 1.3;
  }

  .exp h2 {
    font-size: 1.2rem;
  }

  .exp p,
  .gelişme p,
  .ilişki p,
  .gelişim p,
  .son p {
    font-size: 1rem;
    line-height: 1.7;
  }

  .exp ul {
    padding-left: 1.25rem;
  }

  .start h3 {
    text-align: center;
    font-size: 1rem;
  }

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

@media (min-width: 601px) and (max-width: 900px) {
  .enneagram-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Type pages: media cards and lightbox */
.type-card img {
  aspect-ratio: 4 / 5;
  height: auto;
}

.lightbox.is-open {
  display: flex;
}

.lightbox .close-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  top: 12px;
  right: 12px;
  border: 0;
  border-radius: 999px;
  background: #ffffff1a;
  line-height: 1;
}

/* Contact form */
#contact-form label {
  display: block;
  font-weight: 600;
  color: var(--text-strong);
}

#contact-form input,
#contact-form select,
#contact-form textarea {
  width: 100%;
  padding: 12px;
  margin: 6px 0 16px;
  font-family: inherit;
  font-size: 1rem;
  min-height: 48px;
  background: #101016;
  color: var(--text-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

#contact-form button[type="submit"] {
  min-height: 48px;
  padding: 0.7rem 2rem;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

#contact-form button[type="submit"]:hover {
  background: var(--primary-hover);
}

#contact-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: progress;
}

#sent {
  margin-top: 1rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Shared footer links (tools/sync-header.py) ---------- */

.site-footer {
  display: grid;
  gap: 0.6rem;
  justify-items: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.2rem;
}

.footer-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--text-strong);
  text-decoration: underline;
}

.footer-note {
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ---------- Type pages: character text cards ---------- */

.type-card.type-card--text {
  cursor: default;
  padding: 1rem 1.1rem;
}

.type-card--text p {
  margin-top: 0.5rem;
  line-height: 1.6;
}
