/* ------------------------------------------------------------
   Base typography + layout
------------------------------------------------------------ */

:root {
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --muted_2: #9ca3af;

  --border: #e5e7eb;
  --border_2: #d1d5db;

  --link: #1d4ed8;
  --link_hover: #1e40af;

  --surface: #f9fafb;
  --surface_2: #f3f4f6;

  --code_bg: #f3f4f6;
  --code_border: #e5e7eb;

  --pre_bg: #fbf7d1;
  --pre_border: #eadf9a;

  --note_bg: #e6f0f6;
  --note_border: #b8d1df;

  --radius: 10px;
  --radius_sm: 8px;

  --shadow_sm: 0 1px 2px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

html, body { background: var(--bg); color: var(--fg); }

body {
  margin: 0;
  min-width: 95vw;
  height: 90%;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

a, a:visited { color: var(--link); }
a:hover { color: var(--link_hover); text-decoration: none; }
a:focus-visible {
  outline: 2px solid rgba(29,78,216,0.35);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------
   Content elements
------------------------------------------------------------ */

main {
  p, ol, ul { margin: 1em 0; }
  li { margin: 0.4em 0; }

  h1, h2, h3 {
    margin: 0 0 0.6em 0;
    line-height: 1.15;
    letter-spacing: -0.015em;
  }

  h1 { font-size: 2.0rem; margin-top: 0.2em; }
  h2 { font-size: 1.35rem; margin-top: 1.4em; padding-top: 0.2em; }
  h3 { font-size: 1.1rem; margin-top: 1.2em; }

  hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.6em 0;
  }
}

code {
  background: var(--code_bg);
  border: 1px solid var(--code_border);
  border-radius: 7px;
  padding: 0.18em 0.45em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
}

p code { white-space: nowrap; }

pre {
  background: var(--pre_bg);
  border: 1px solid var(--pre_border);
  padding: 1em 1.1em;
  border-radius: var(--radius_sm);
  box-shadow: var(--shadow_sm);
  overflow-x: auto;
  font-size: 1.02em;
  line-height: 1.55;

  & > code {
    padding: 0;
    border: none;
    background: transparent;
    white-space: pre;
  }
}

ol.footnotes {
  margin: 2.2em 0 0 0;
  padding: 1.6em 0 0 1.5em;
  border-top: 1px solid var(--border_2);
  font-size: 0.9em;
  line-height: 1.65;

  li { margin: 0; padding: 0; }
}

/* Notes */
._note {
  margin: 1em 0;
  padding: 1em 1.1em 1.1em 1.2em;
  border-radius: var(--radius_sm);
  border: 1px solid var(--note_border);
  background: var(--note_bg);
  box-shadow: var(--shadow_sm);

  &::before {
    display: block;
    font-weight: 700;
    margin-bottom: 0.55em;
    letter-spacing: 0.06em;
    color: #355c73;
  }

  p:first-child { margin-top: 0; }
  p:last-child { margin-bottom: 0; }

  &.note {
    &::before { content: "NOTE"; }
    font-size: 0.96em;
  }
}

/* ------------------------------------------------------------
   Shrimple static site shell
------------------------------------------------------------ */

.shrimple-static-site {
  display: flex;
  width: 100%;
  height: 100%;
  padding: 2em;
  gap: 2em;
  align-items: stretch;

  menu {
    width: 280px;
    min-width: 280px;
    height: calc(100vh - 4em);
    margin: 0;
    padding: 1em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow_sm);
    overflow: auto;

    & > dd { margin: 0; }
    dd, summary { margin-bottom: 0.45em; }

    details {
      margin-bottom: 0.6em;

      dd { margin-left: 1.2em; }
      summary {
        color: var(--link);
        cursor: pointer;
        font-weight: 600;
        text-decoration: none;
        padding: 0.25em 0.3em;
        border-radius: 7px;

        &:hover { background: var(--surface_2); }
      }
    }

    a {
      display: inline-block;
      padding: 0.25em 0.35em;
      border-radius: 7px;
      text-decoration: none;

      &:hover { background: var(--surface_2); }

      &.current {
        background: #e8eefc;
        color: var(--fg);
        box-shadow: inset 0 0 0 1px rgba(29,78,216,0.18);
      }
    }
  }

  main {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 980px;

    div.content {
      flex-grow: 1;
      padding: 0.2em 0.2em 1.2em 0.2em;
    }

    nav {
      display: flex;
      justify-content: space-between;
      gap: 1em;
      width: 100%;
      padding-top: 1em;
      border-top: 1px solid var(--border);

      a.previous, a.next {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        box-shadow: var(--shadow_sm);
        padding: 0.95em 1em;
        width: min(360px, 48%);
        border-radius: var(--radius);
        font-size: 1.05em;
        text-decoration: none;
        color: var(--fg);

        &:hover {
          background: #eef5ff;
          border-color: rgba(29,78,216,0.25);
        }
      }

      a.previous {
        text-align: left;

        &::before {
          content: "Previous";
          font-size: 0.85em;
          color: var(--muted);
          display: block;
          margin-bottom: 0.15em;
        }
      }

      a.next {
        text-align: right;

        &::before {
          content: "Next";
          font-size: 0.85em;
          color: var(--muted);
          display: block;
          margin-bottom: 0.15em;
        }
      }
    }
  }
}

/* ------------------------------------------------------------
   Small screen behavior
------------------------------------------------------------ */

@media (max-width: 980px) {
  .shrimple-static-site {
    padding: 1.2em;
    gap: 1.2em;
    flex-direction: column;

    menu {
      width: 100%;
      min-width: 0;
      height: auto;
      max-height: 40vh;
    }

    main {
      max-width: 100%;

      nav {
        a.previous, a.next { width: 100%; }
      }
    }
  }
}
