/* ==========================================================================
   PHI OS Platform
   Landing page and shared platform presentation
   ========================================================================== */

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

html {
  width: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  width: 100%;
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.skip-link {
  position: fixed;
  top: 0;
  left: 1rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transform: translateY(calc(-100% - 1rem));
  transition: transform 0.18s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(1rem);
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* ==========================================================================
   Platform header
   ========================================================================== */

.platform-header {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 82px;
  padding: 0 clamp(1.25rem, 4vw, 4.5rem);
  pointer-events: none;
}

.platform-header > * {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1;
}

.brand-wordmark {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.platform-header-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.language-switcher,
.journey-switcher {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 8px 30px rgba(20, 24, 33, 0.03);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.language-switcher {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.55rem 0.78rem;
  color: var(--ink-soft);
}

.language-option {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 0.76rem;
  cursor: pointer;
}

.language-option:hover,
.language-option:focus-visible,
.language-option.is-active {
  color: var(--ink);
}

.language-option.is-active {
  font-weight: 600;
}

.journey-switcher {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.1rem;
  padding: 0.62rem 1rem;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.journey-switcher:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.82);
}

.journey-switcher:active {
  transform: translateY(1px);
}

/* ==========================================================================
   Journey switcher panel
   ========================================================================== */

.journey-panel {
  position: fixed;
  top: 5.4rem;
  right: clamp(1rem, 3vw, 3rem);
  z-index: 100;
  width: min(430px, calc(100vw - 2rem));
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(253, 252, 249, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.journey-panel nav {
  display: grid;
}

.journey-panel a {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.22rem 0.8rem;
  padding: 1rem;
  border-radius: 0.8rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 160ms ease;
}

.journey-panel a:hover,
.journey-panel a:focus-visible {
  background: #f0eee7;
}

.journey-panel span {
  grid-row: 1 / 3;
  padding-top: 0.15rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.journey-panel strong {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.1;
}

.journey-panel small {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ==========================================================================
   Main entry stage
   ========================================================================== */

main {
  display: block;
  width: 100%;
}

.entry-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100svh;
  padding:
    clamp(8.5rem, 14vh, 10.5rem)
    clamp(1.25rem, 5vw, 5rem)
    clamp(4rem, 8vh, 6rem);
  overflow: hidden;
  isolation: isolate;
}

.entry-stage::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  content: "";
  background:
    radial-gradient(
      circle at 50% 42%,
      rgba(255, 255, 255, 0.98) 0%,
      rgba(248, 247, 243, 0.82) 38%,
      rgba(245, 243, 237, 0.42) 62%,
      transparent 78%
    );
  pointer-events: none;
}

.entry-orbit {
  position: absolute;
  top: 44%;
  left: 50%;
  z-index: -1;
  width: min(760px, 72vw, 78vh);
  aspect-ratio: 1;
  opacity: 0.27;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.entry-orbit span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.entry-orbit span:nth-child(2) {
  inset: 15%;
  border-radius: 2px;
  transform: rotate(45deg);
}

.entry-orbit span:nth-child(3) {
  inset: 31%;
  border-color: rgba(36, 47, 122, 0.3);
}

.entry-copy,
.entry-form,
.domain-prompts,
.privacy-note {
  position: relative;
  z-index: 2;
  width: min(820px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.entry-copy {
  text-align: center;
}

.eyebrow {
  margin: 0 0 1.15rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.17em;
  line-height: 1.4;
  text-transform: uppercase;
}

.entry-copy h1 {
  max-width: 900px;
  margin: 0 auto 1.35rem;
  font-family: var(--serif);
  font-size: clamp(3.5rem, 6.2vw, 6.4rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.96;
  text-wrap: balance;
}

.entry-intro {
  max-width: 670px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.35vw, 1.15rem);
  line-height: 1.55;
  text-wrap: pretty;
}

/* ==========================================================================
   Entry form
   ========================================================================== */

.entry-form {
  margin-top: clamp(2.2rem, 5vh, 3.2rem);
}

.entry-form textarea {
  display: block;
  width: 100%;
  min-height: 142px;
  padding: 1.3rem 1.4rem;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  outline: none;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 48px rgba(30, 35, 48, 0.055);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.6;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.entry-form textarea::placeholder {
  color: color-mix(in srgb, var(--ink-soft) 78%, transparent);
}

.entry-form textarea:hover {
  background: rgba(255, 255, 255, 0.84);
}

.entry-form textarea:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 0 0 4px rgba(36, 47, 122, 0.08),
    0 18px 54px rgba(30, 35, 48, 0.065);
}

.entry-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1rem;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-height: 48px;
  padding: 0.84rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(17, 20, 28, 0.12);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.primary-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(17, 20, 28, 0.17);
}

.primary-action:active:not(:disabled) {
  transform: translateY(0);
}

.primary-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

.form-message {
  margin: 0 auto 0 0;
  color: var(--danger);
  font-size: 0.86rem;
}

.domain-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 1.6rem;
}

.domain-prompts button {
  min-height: 40px;
  padding: 0.5rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: var(--ink-soft);
  font-size: 0.78rem;
  cursor: pointer;
  transition:
    color 150ms ease,
    border-color 150ms ease,
    background-color 150ms ease;
}

.domain-prompts button:hover,
.domain-prompts button:focus-visible {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.privacy-note {
  margin-top: 1.35rem;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.5;
  text-align: center;
}

/* ==========================================================================
   Shared section headings
   ========================================================================== */

.journey-map,
.runtime-principles {
  width: min(var(--max), calc(100% - 3rem));
  margin: 0 auto;
  padding: clamp(5rem, 9vw, 8rem) 0;
}

.section-heading {
  max-width: 850px;
  margin-bottom: clamp(2.8rem, 5vw, 4rem);
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.65rem, 5vw, 4.9rem);
  font-weight: 500;
  letter-spacing: -0.037em;
  line-height: 1.02;
  text-wrap: balance;
}

.section-heading.compact h2 {
  font-size: clamp(2.35rem, 4vw, 3.8rem);
}

/* ==========================================================================
   Journey map
   ========================================================================== */

.journey-card {
  display: grid;
  grid-template-columns:
    minmax(210px, 0.72fr)
    minmax(360px, 1.45fr)
    auto;
  gap: clamp(1.5rem, 3vw, 2.8rem);
  align-items: start;
  padding: clamp(2rem, 4vw, 3rem) 0;
  border-top: 1px solid var(--line);
}

.journey-card:last-child {
  border-bottom: 1px solid var(--line);
}

.journey-card header {
  display: flex;
  gap: 1.15rem;
  min-width: 0;
}

.journey-card header > span {
  flex: 0 0 auto;
  padding-top: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.journey-card header > div {
  min-width: 0;
}

.journey-card header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  line-height: 1.45;
  text-transform: uppercase;
}

.journey-card h3 {
  margin: 0.35rem 0 0;
  font-family: var(--serif);
  font-size: clamp(1.75rem, 2.5vw, 2.25rem);
  font-weight: 500;
  line-height: 1.05;
}

.journey-card ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem 1.5rem;
  min-width: 0;
  padding: 0;
  margin: 0;
  list-style: none;
}

.journey-card li {
  display: grid;
  align-content: start;
  gap: 0.18rem;
  min-width: 0;
}

.journey-card li strong {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
}

.journey-card li span {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.45;
}

.journey-card > a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  color: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
}

.journey-card > a:hover span:first-child {
  text-decoration: underline;
  text-underline-offset: 0.25rem;
}

.journey-card--reality h3,
.journey-card--reality > a {
  color: var(--reality);
}

.journey-card--knowledge h3,
.journey-card--knowledge > a {
  color: var(--knowledge);
}

.journey-card--platform h3,
.journey-card--platform > a {
  color: var(--platform);
}

/* ==========================================================================
   Runtime principles
   ========================================================================== */

.runtime-principles {
  padding-top: clamp(4rem, 7vw, 6.5rem);
}

.principle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.principle-grid article {
  min-height: 220px;
  padding: 1.45rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.principle-grid article > span {
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.principle-grid h3 {
  margin: 3rem 0 0.8rem;
  font-family: var(--serif);
  font-size: 1.42rem;
  font-weight: 500;
  line-height: 1.12;
}

.principle-grid p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.83rem;
  line-height: 1.55;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.platform-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  width: min(var(--max), calc(100% - 3rem));
  margin: 2rem auto 0;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
}

.platform-footer > div {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.platform-footer p {
  margin: 0;
  font-size: 0.84rem;
}

.platform-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.platform-footer a {
  min-height: 40px;
  color: inherit;
  font-size: 0.84rem;
  line-height: 40px;
  text-decoration: none;
}

.platform-footer a:hover {
  color: var(--ink);
}

/* ==========================================================================
   Chinese interface typography
   ========================================================================== */

html[lang="zh-Hans"] body {
  line-height: 1.7;
}

html[lang="zh-Hans"] .entry-copy h1,
html[lang="zh-Hans"] .section-heading h2,
html[lang="zh-Hans"] .journey-card h3,
html[lang="zh-Hans"] .journey-panel strong,
html[lang="zh-Hans"] .principle-grid h3 {
  letter-spacing: -0.025em;
}

html[lang="zh-Hans"] .entry-copy h1 {
  max-width: 820px;
  font-size: clamp(3.3rem, 5.7vw, 5.8rem);
  line-height: 1.08;
}

html[lang="zh-Hans"] .entry-intro {
  max-width: 720px;
  line-height: 1.75;
}

html[lang="zh-Hans"] .eyebrow,
html[lang="zh-Hans"] .journey-card header p {
  letter-spacing: 0.12em;
}

/* ==========================================================================
   Tablet
   ========================================================================== */

@media (max-width: 1020px) {
  .entry-stage {
    padding-right: 2rem;
    padding-left: 2rem;
  }

  .entry-copy h1 {
    font-size: clamp(3.5rem, 8vw, 5.5rem);
  }

  .journey-card {
    grid-template-columns: minmax(190px, 0.7fr) minmax(0, 1.3fr);
  }

  .journey-card > a {
    grid-column: 2;
    justify-self: start;
  }

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

@media (max-width: 760px) {
  .platform-header {
    min-height: 74px;
    padding: 0 1rem;
  }

  .brand-wordmark {
    font-size: 0.76rem;
  }

  .platform-header-actions {
    gap: 0.45rem;
  }

  .journey-switcher {
    gap: 0.55rem;
    padding-right: 0.78rem;
    padding-left: 0.78rem;
  }

  .entry-stage {
    min-height: auto;
    padding:
      8.5rem
      1.25rem
      4.5rem;
  }

  .entry-orbit {
    top: 35%;
    width: min(92vw, 610px);
  }

  .entry-copy h1 {
    max-width: 680px;
    font-size: clamp(3.15rem, 10vw, 4.8rem);
  }

  html[lang="zh-Hans"] .entry-copy h1 {
    font-size: clamp(3rem, 9vw, 4.4rem);
  }

  .entry-form {
    margin-top: 2.4rem;
  }

  .journey-map,
  .runtime-principles {
    width: min(100% - 2rem, var(--max));
  }

  .journey-card {
    grid-template-columns: 1fr;
    gap: 1.6rem;
  }

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

  .journey-card > a {
    grid-column: 1;
  }

  .section-heading {
    margin-bottom: 2.5rem;
  }

  .section-heading h2 {
    font-size: clamp(2.5rem, 8vw, 3.8rem);
  }
}

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 560px) {
  .platform-header {
    align-items: flex-start;
    min-height: 68px;
    padding-top: 0.8rem;
  }

  .brand {
    min-height: 40px;
  }

  .brand-mark {
    font-size: 1.7rem;
  }

  .brand-wordmark {
    display: none;
  }

  .platform-header-actions {
    gap: 0.35rem;
  }

  .language-switcher,
  .journey-switcher {
    min-height: 40px;
  }

  .language-switcher {
    padding: 0.4rem 0.55rem;
  }

  .journey-switcher {
    max-width: 132px;
    padding: 0.48rem 0.68rem;
    font-size: 0.74rem;
  }

  .journey-switcher span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .journey-panel {
    top: 4.5rem;
    right: 0.75rem;
    width: calc(100vw - 1.5rem);
  }

  .entry-stage {
    justify-content: flex-start;
    padding:
      7.8rem
      1rem
      3.8rem;
  }

  .entry-orbit {
    top: 30%;
    width: 115vw;
    opacity: 0.2;
  }

  .eyebrow {
    margin-bottom: 0.9rem;
    font-size: 0.63rem;
  }

  .entry-copy h1 {
    max-width: 100%;
    margin-bottom: 1.1rem;
    font-size: clamp(2.75rem, 14vw, 3.75rem);
    line-height: 0.98;
  }

  html[lang="zh-Hans"] .entry-copy h1 {
    font-size: clamp(2.65rem, 12vw, 3.45rem);
    line-height: 1.12;
  }

  .entry-intro {
    font-size: 0.96rem;
    line-height: 1.58;
  }

  .entry-form {
    margin-top: 2rem;
  }

  .entry-form textarea {
    min-height: 132px;
    padding: 1rem;
    border-radius: 1rem;
    font-size: 16px;
  }

  .entry-actions {
    align-items: stretch;
    flex-direction: column;
    margin-top: 0.8rem;
  }

  .primary-action {
    width: 100%;
    min-height: 50px;
  }

  .form-message {
    width: 100%;
    margin: 0;
  }

  .domain-prompts {
    justify-content: flex-start;
    gap: 0.45rem;
    margin-top: 1.25rem;
  }

  .domain-prompts button {
    min-height: 40px;
    padding: 0.45rem 0.68rem;
    font-size: 0.73rem;
  }

  .privacy-note {
    margin-top: 1.15rem;
    font-size: 0.7rem;
  }

  .journey-map,
  .runtime-principles {
    width: calc(100% - 2rem);
    padding: 4.5rem 0;
  }

  .section-heading h2 {
    font-size: clamp(2.35rem, 11vw, 3.1rem);
    line-height: 1.04;
  }

  .journey-card {
    gap: 1.4rem;
    padding: 2rem 0;
  }

  .journey-card header {
    gap: 0.8rem;
  }

  .journey-card h3 {
    font-size: 1.9rem;
  }

  .journey-card ol {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding-left: 2.15rem;
  }

  .journey-card > a {
    margin-left: 2.15rem;
    white-space: normal;
  }

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

  .principle-grid article {
    min-height: auto;
    padding: 1.25rem;
  }

  .principle-grid h3 {
    margin-top: 2rem;
  }

  .platform-footer {
    align-items: flex-start;
    flex-direction: column;
    width: calc(100% - 2rem);
    gap: 1.3rem;
    padding-bottom: 2rem;
  }

  .platform-footer > div {
    align-items: flex-start;
  }

  .platform-footer nav {
    width: 100%;
  }
}

/* ==========================================================================
   Small mobile
   ========================================================================== */

@media (max-width: 390px) {
  .journey-switcher {
    max-width: 108px;
  }

  .entry-copy h1 {
    font-size: 2.75rem;
  }

  html[lang="zh-Hans"] .entry-copy h1 {
    font-size: 2.55rem;
  }

  .entry-stage {
    padding-right: 0.85rem;
    padding-left: 0.85rem;
  }

  .domain-prompts button {
    max-width: 100%;
  }
}

/* ==========================================================================
   Reduced motion and high-contrast preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-contrast: more) {
  .language-switcher,
  .journey-switcher,
  .entry-form textarea,
  .domain-prompts button,
  .journey-panel {
    border-color: currentColor;
  }
}
