/* Port of Call: one stylesheet, read top to bottom.
   1 tokens  2 base  3 rail navigation  4 page  5 tiles */

/* 1. Tokens */
:root {
  color-scheme: dark light;
  --bg: #1d1024;
  --surface: #2c1838;
  --surface-2: #3a2148;
  --text: #ece4f0;
  --muted: #b9a9c2;
  --purple: #b55fd8;
  --yellow: #f2d23c;

  --font: system-ui, "Segoe UI", Roboto, sans-serif;
  --rail: 4.5rem;
  --rail-open: 14rem;
  --space: clamp(1rem, 3vw, 2rem);
  --radius: 0.75rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f0fa;
    --surface: #ead9f2;
    --surface-2: #ffffff;
    --text: #241a29;
    --muted: #5e4f66;
    --purple: #7b1fa2;
    --yellow: #7a5c00;
  }
}

/* 2. Base */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
}

a { color: var(--yellow); }

:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* 3. Rail navigation: a bottom bar on phones, a side rail that
   widens on hover or keyboard focus on larger screens. */
.rail {
  position: fixed;
  z-index: 2;
  inset: auto 0 0 0;
  background: var(--surface);
  box-shadow: 0 -2px 10px rgb(0 0 0 / 0.25);

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

  li { flex: 1; }

  a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.6rem 0.25rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
  }

  a:hover,
  a:focus-visible {
    background: var(--surface-2);
    color: var(--yellow);
  }

  svg {
    width: 1.6rem;
    height: 1.6rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .rail-logo { display: none; }
}

@media (min-width: 40rem) {
  .rail {
    inset: 0 auto 0 0;
    width: var(--rail);
    overflow: hidden;
    box-shadow: 2px 0 10px rgb(0 0 0 / 0.25);
    transition: width 0.25s ease;

    ul {
      flex-direction: column;
      height: 100%;
    }

    li { flex: none; }
    li:last-child { margin-top: auto; }

    a {
      flex-direction: row;
      gap: 2rem; /* keeps labels outside the collapsed rail */
      height: var(--rail);
      padding: 0 1.45rem;
      font-size: 1rem;
      white-space: nowrap;
    }

    span {
      opacity: 0;
      transition: opacity 0.2s;
    }

    .rail-logo {
      display: block;

      a {
        background: var(--purple);
        color: var(--bg);
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
      }

      svg { transition: transform 0.3s; }
    }
  }

  .rail:hover,
  .rail:focus-within {
    width: var(--rail-open);

    span { opacity: 1; }
    .rail-logo svg { transform: rotate(180deg); }
  }
}

/* 4. Page */
.page {
  padding-bottom: 5rem;
}

@media (min-width: 40rem) {
  .page {
    margin-left: var(--rail);
    padding-bottom: 0;
  }
}

.intro,
.area,
.footer {
  max-width: 62rem;
  margin-inline: auto;
  padding: var(--space);
}

.intro {
  padding-block: clamp(3rem, 12vw, 7rem) clamp(1rem, 4vw, 2rem);
}

.version {
  margin: 0;
  color: var(--purple);
  font-family: ui-monospace, monospace;
}

h1 {
  margin: 0.2em 0;
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.lead {
  max-width: 55ch;
  color: var(--muted);
  font-size: 1.1rem;
}

h2 {
  margin: 0 0 1rem;
  color: var(--purple);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.area { scroll-margin-top: 1rem; }

.footer {
  color: var(--muted);
  font-size: 0.9rem;
}

/* 5. Tiles */
.tiles {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;

  a,
  div {
    display: block;
    height: 100%;
    padding: 1.1rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
  }

  a:hover,
  a:focus-visible {
    border-color: var(--yellow);
    background: var(--surface-2);
  }

  strong {
    display: block;
    margin-bottom: 0.2rem;
  }

  a strong { color: var(--yellow); }

  span {
    color: var(--muted);
    font-size: 0.95rem;
  }
}
