/* ==========================================================================
   Portfolio — Watanabe Yoshikatsu
   見た目は rfc-editor.org の RFC 情報ページ（/info/rfcXXXX/）の構成に倣う。
   トークンの定義と根拠は DESIGN.md を参照。
   ========================================================================== */

:root {
    /* palette (light) */
    --header-bg: #002d3c;
    --header-hover: #001d2c;
    --header-border: #ffffff;
    --page-bg: #ffffff;
    --ink: #000000;
    --ink-soft: #1e2939;
    --muted: #4a5565;
    --link: #1c62b6;
    --link-hover: #155dfc;
    --link-strong: #002d3c;
    --tag-bg: #d3e3ff;
    --tag-border: #b3b3ff;
    --tag-ink: #1c62b6;
    --badge-bg: #18539b;
    --badge-ink: #ffffff;
    --diamond-bg: #ffd13e;
    --diamond-ink: #000000;
    --rule: #d1d5dc;
    --rule-strong: #99a1af;
    --hover-bg: #e0f2fe;

    --font-sans: "Inter", "Noto Sans JP", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", "Noto Sans JP", monospace;

    --container: 80rem;
    --rfc-container: 1160px;
    --sidebar-width: 400px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --header-bg: #00101c;
    --header-hover: #001d2c;
    --header-border: #002d3c;
    --page-bg: #00070f;
    --ink: #ffffff;
    --ink-soft: #e5e7eb;
    --muted: #99a1af;
    --link: #3cc0fd;
    --link-hover: #0b8cc5;
    --link-strong: #ffffff;
    --tag-bg: #193cb8;
    --tag-border: #1c62b6;
    --tag-ink: #ffffff;
    --badge-bg: #193cb8;
    --badge-ink: #ffffff;
    --diamond-bg: #894b00;
    --diamond-ink: #ffffff;
    --rule: #364153;
    --rule-strong: #6a7282;
    --hover-bg: #002d3c;

    color-scheme: dark;
}

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

html { scroll-padding-top: 1rem; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--page-bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover, a:focus-visible { color: var(--link-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
}

.nowrap { white-space: nowrap; }

/* language switch: each text exists in both languages; hide the other one */
html[lang="ja"] [data-l="en"],
html[lang="en"] [data-l="ja"] { display: none !important; }
.w-normal { font-weight: 400; }
.w-medium { font-weight: 500; }
.w-bold { font-weight: 700; }

.skip {
    position: absolute;
    left: 40%;
    top: 0;
    margin: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #fff;
    color: #000;
    transform: translateY(-4em);
    opacity: 0;
    z-index: 10;
}
.skip:focus { transform: none; opacity: 1; }

/* --- Two-column layout ----------------------------------------------------- */

.layout {
    display: flex;
    gap: 1.25rem;
    max-width: var(--container);
    margin: 0 auto;
    padding: 2.5rem 0.75rem 4.5rem 60px;
    width: 100%;
    flex: 1;
}

.doc { flex: 0 1 740px; min-width: 0; padding: 0 0 0 1rem; }

.doc__title {
    margin: 1rem 0 0.5rem 0;
    font-size: 48px;
    font-weight: 600;
    line-height: 1.2;
    overflow-wrap: anywhere;
}
.doc__title > span,
.doc__series { white-space: nowrap; }
.doc__series {
    color: var(--ink-soft);
    text-decoration: underline;
    text-decoration-color: #6a7282;
    text-decoration-thickness: 3px;
    text-underline-offset: 6px;
}
.doc__series:hover { color: var(--ink-soft); text-decoration-color: var(--ink); }




.updated {
    margin: 0.25rem 0 0 2px;
    font-size: 14px;
    color: var(--ink-soft);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem;
    list-style: none;
    margin: 0.5rem 0 0 -12px;
    padding: 0 0 0 0.125rem;
    font-size: 14px;
}
.actions li {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 1rem 0.25rem 0.5rem;
}
.actions li + li { border-left: 1px solid var(--rule); }

.action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.125rem 0.25rem;
    border: 2px solid transparent;
    border-radius: 4px;
    background: none;
    color: var(--link);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.action svg { width: 20px; height: 20px; }
.action:hover,
.action:focus-visible {
    color: var(--badge-bg);
    background: var(--hover-bg);
    border-color: var(--ink);
    text-decoration: none;
}
[data-theme="dark"] .action:hover { color: #fff; border-color: #d3e3ff; }
.action__stat { padding-left: 2.1rem; font-size: 12px; }


/* --- Memo body: plain-text RFC look ---------------------------------------- */

.memo {
    margin-top: 2rem;
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1.5;
    font-feature-settings: "calt" 0;
}

.memo pre {
    margin: 0;
    font: inherit;
    white-space: pre;
    overflow-x: auto;
}

.memo a { color: var(--link); text-decoration: underline; text-decoration-color: currentColor; }
.memo a:hover { color: var(--link-hover); }


/* every block ends with one blank line (one line-height), like plain-text RFCs */
.blk { margin: 0 0 1.5rem !important; }

.mh {
    margin: 0 0 1.5rem;
    font: inherit;
    font-weight: 400;
}


/* prose lives outside <pre> so it wraps; indent matches the 3-space RFC indent */
.t {
    max-width: 72ch;
    margin: 0 0 1.5rem;
    padding: 0 0 0 3ch;
    line-break: strict;
    word-break: normal;
    overflow-wrap: anywhere;
}

.credit {
    max-width: 72ch;
    margin: 3rem 0 0;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--muted);
}
.memo .credit a { color: var(--muted); }
.memo .credit a:hover { color: var(--link); }

/* Japanese table of contents: dot leaders without fixed-width alignment */
.toc-ja { list-style: none; max-width: 69ch; }
.toc-ja li { display: flex; align-items: baseline; }
.toc-ja .dots { flex: 1; overflow: hidden; white-space: nowrap; }
.toc-ja .dots::before { content: "................................................................................................................"; }

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0 2ch;
}
.facts dt,
.facts dd { margin: 0; }

.rows { list-style: none; }
.rows li { display: flex; gap: 2ch; }
.rows__date { flex: none; color: var(--ink); }

/* --- Sidebar --------------------------------------------------------------- */

.side {
    position: relative;
    flex: none;
    width: var(--sidebar-width);
    margin-left: auto;
    padding-left: 0.75rem;
    font-size: 14px;
}

/* follows the reader down the page; the panel scrolls on its own */
.side__inner {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    max-height: 100vh;
}

/* collapse handle: icon hangs left of the sidebar, a thin strip lights up on hover */
.side__toggle {
    position: absolute;
    top: 14px;
    left: -28px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: var(--page-bg);
    outline: 2px solid var(--page-bg);
    color: var(--ink-soft);
    cursor: e-resize;
    z-index: 2;
}
.side__toggle::before {
    content: "";
    position: absolute;
    top: -14px;
    right: 0;
    width: 8px;
    height: 100vh;
    z-index: -1;
}
.side__toggle:hover,
.side__toggle:focus-visible { background: var(--rule); outline: 0; color: var(--ink); }
.side__toggle:hover::before,
.side__toggle:focus-visible::before { background: var(--rule); }
.side__toggle svg { display: block; width: 24px; height: 24px; }

@media (min-width: 1024px) {
    .side.is-collapsed { width: 0; padding-left: 0; }
    .side.is-collapsed .side__inner > :not(.side__toggle) { display: none; }
    .side.is-collapsed .side__toggle { cursor: w-resize; }
    .side.is-collapsed .side__toggle svg { transform: scaleX(-1); }
}

.side__close,
.info-btn { display: none; }

.tabs {
    flex: none;
    display: flex;
    gap: 1.25rem;
    border-bottom: 2px solid var(--rule-strong);
    background: var(--page-bg);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs button {
    padding: 1rem 1px;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: none;
    color: var(--ink-soft);
    font: inherit;
    white-space: nowrap;
    cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:hover { color: var(--link); }

.diamond {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 20px;
    height: 20px;
    margin-left: 0.4rem;
    background: var(--diamond-bg);
    color: var(--diamond-ink);
    font-size: 12px;
    font-weight: 600;
    clip-path: polygon(0 50%, 50% 0, 100% 50%, 50% 100%);
}

.panel {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem 1rem 0.5rem;
}

.toc { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 0.5rem 0; color: var(--link); }
.toc a.is-active { font-weight: 600; }

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

/* --- Responsive ------------------------------------------------------------ */

@media (max-width: 1023px) {
    /* mobile: the sidebar opens as a drawer from the "Info" button, like the original */
    .side { display: none; }
    .side__toggle { display: none; }
    .side.is-open {
        display: block;
        position: fixed;
        inset: 0;
        width: auto;
        margin: 0;
        padding: 0;
        background: rgb(0 0 0 / 0.5);
        z-index: 50;
    }
    .side.is-open .side__inner {
        display: flex;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(400px, 88vw);
        max-height: none;
        padding: 0 0.75rem;
        background: var(--page-bg);
        box-shadow: -8px 0 24px rgb(0 0 0 / 0.3);
    }
    .side__close {
        display: flex;
        align-self: flex-end;
        margin: 0.5rem 0 -0.5rem;
        padding: 0.5rem;
        border: 0;
        background: none;
        color: var(--ink);
        cursor: pointer;
    }
    .side__close svg { width: 22px; height: 22px; }
    .info-btn {
        display: flex;
        align-items: center;
        position: fixed;
        top: 0.75rem;
        right: 0;
        padding: 0.5rem 0.75rem;
        border: 1px solid var(--rule);
        border-right: 0;
        border-radius: 4px 0 0 4px;
        background: var(--page-bg);
        color: var(--ink);
        font: inherit;
        font-size: 14px;
        font-weight: 700;
        box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.25);
        cursor: pointer;
        z-index: 10;
    }
    body.no-scroll { overflow: hidden; }
    .layout { padding-left: 0; padding-right: 0; }
    .doc { flex: 1; padding-right: 1rem; }
    .doc__title { font-size: 30px; }
}

@media (max-width: 767px) {
    .memo { font-size: 13px; }
        .rows li { flex-wrap: wrap; column-gap: 2ch; }
    }

@media print {
    .side, .actions { display: none; }
}
