/*
 * 「始め方の案内」(ブラウザのタブで開いたとき)と「はじめかた」(アカウントの無い端末)。js/roooom-entry.js
 * 見た目は、2026-09-29 にユーザーと決めた試作 docs/prototype/onboarding.html の「アプリの画面」の部分と同じ。
 * アプリの style.css の同じ名前のクラス(.card・.hint・.steps など)に影響しないよう、すべて .entry-guide の中に限る。
 * style.css の button の決まり(高さ44px・白い文字・折り返さない)は、ここで打ち消す。
 */
body.guide-mode { overflow: auto; height: auto; min-height: 100dvh; display: block; background: #f0f2f5; }
html:has(body.guide-mode) { overflow: auto; height: auto; }
body.guide-mode .layer,
body.guide-mode #critical-error-overlay { display: none !important; }
body.welcome-open { overflow: hidden; }

.entry-guide {
    --color-main: #329e91;
    --color-main-dark: #2a7f75;
    --text: #2c3e50;
    --text-sub: #5d6d7e;
    --text-muted: #7f8c8d;
    --line: #e3e7eb;
    --warn-bg: #fff4e5;
    --warn-text: #8a4b00;
    min-height: 100dvh;
    background: #f0f2f5;
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
    -webkit-font-smoothing: antialiased;
    padding-top: var(--safe-top, 0px);
    padding-bottom: var(--safe-bottom, 0px);
}
.entry-welcome { position: fixed; inset: 0; z-index: 900; overflow-y: auto; }

.entry-guide .page { max-width: 440px; margin: 0 auto; padding: 20px 16px 28px; display: flex; flex-direction: column; gap: 14px; }
.entry-guide .logo { display: block; height: 1.7rem; width: auto; aspect-ratio: 993.13 / 218.13; color: var(--color-main); margin: 6px auto 2px; }
/* 見出しは、文の区切り(<wbr>)だけで折り返す(「つど／い」のように語の途中で切らない)。入りきらないときだけ、どこでも折り返す */
.entry-guide .page h2 { font-size: 1.25rem; line-height: 1.45; margin: 0; text-align: center; font-weight: 700; word-break: keep-all; overflow-wrap: anywhere; }
/* アプリの .lead(文の強弱の要点。style.css)とは別の見た目。太さと折り返しも、ここで決める */
.entry-guide .lead { margin: 0; font-size: 0.92rem; line-height: 1.7; color: var(--text-sub); font-weight: 400; word-break: normal; }
.entry-guide .lead-strong { color: var(--text); }
.entry-guide .card {
    background: white; padding: 18px; border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03); border: 1px solid #f0f0f0;
    display: flex; flex-direction: column; gap: 12px;
}
.entry-guide .card-title { font-size: 0.8rem; font-weight: 700; color: var(--color-main-dark); }
.entry-guide .card-title-strong { font-size: 0.95rem; color: var(--text); }
.entry-guide .hint { font-size: 0.8rem; color: var(--text-muted); line-height: 1.55; margin: 0; }
.entry-guide .hint-body { font-size: 0.88rem; color: var(--text-sub); }
.entry-guide .hint a, .entry-guide .foot-links a { color: var(--text-muted); }
.entry-guide .big-code { text-align: center; font-size: 1.45rem; letter-spacing: 0.08em; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all; -webkit-user-select: all; outline: none; }
.entry-guide .big-code-long { font-size: 0.8rem; word-break: break-all; letter-spacing: 0; }
.entry-guide .copied-mark { margin: 0; text-align: left; color: var(--color-main-dark); font-weight: 700; font-size: 0.9rem; }
.entry-guide .warning-note { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-text); font-size: 0.85rem; line-height: 1.6; }

.entry-guide .btn {
    width: 100%; padding: 0 20px; height: 46px; background-color: var(--color-main); color: white;
    border: none; border-radius: 23px; font-weight: 600; font-size: 0.95rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px; font-family: inherit;
    white-space: normal; text-align: center; text-decoration: none; box-sizing: border-box;
}
.entry-guide .btn:active { transform: scale(0.97); opacity: 0.9; }
.entry-guide .btn.step { background: transparent; color: var(--color-main); border: 1.5px solid var(--color-main); }
.entry-guide .btn.ghost { background: transparent; color: var(--text-sub); border: 1px solid #d1d8e0; }
.entry-guide .btn.small { height: 36px; width: auto; font-size: 0.85rem; padding: 0 16px; flex-shrink: 0; }

/* 進み具合(iPhone で、コードを持って来たときだけ)。数字は付けない */
.entry-guide .progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0 2px; }
.entry-guide .progress div { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.72rem; color: #9aa5ae; position: relative; }
.entry-guide .progress div::before {
    content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c8d0d6; box-sizing: border-box;
    display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; background: #fff; color: #9aa5ae;
}
/* 段階の間の三角(右へ進むことがわかるように。向きの印の決まり .tri の形。style.css)。済んだ段階の後ろは緑 */
.entry-guide .progress div:not(:last-child)::after {
    content: ""; position: absolute; top: 6px; right: -5px; width: 9px; height: 9px; background-color: currentColor; color: #c8d0d6;
    -webkit-mask: var(--mark-tri) center / contain no-repeat; mask: var(--mark-tri) center / contain no-repeat;
}
.entry-guide .progress div.done:not(:last-child)::after { color: var(--color-main); }
.entry-guide .progress div.done { color: var(--color-main-dark); }
.entry-guide .progress div.done::before { content: "✓"; background: var(--color-main); border-color: var(--color-main); color: #fff; }
.entry-guide .progress div.now { color: var(--text); font-weight: 700; }
.entry-guide .progress div.now::before { border-color: var(--color-main); color: var(--color-main); box-shadow: 0 0 0 3px rgba(50,158,145,0.15); }

/* 手順 */
.entry-guide .steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.entry-guide .steps li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 0.9rem; line-height: 1.65; }
.entry-guide .steps li.next { background: #eef5f4; border-radius: 12px; margin: -6px -8px; padding: 6px 8px; }
.entry-guide .steps li::before {
    content: attr(data-n); width: 24px; height: 24px; border-radius: 50%; background: #eef5f4; color: var(--color-main-dark);
    font-size: 0.78rem; font-weight: 700; display: grid; place-items: center; margin-top: 2px;
}
.entry-guide .glyph { display: inline-flex; vertical-align: -4px; width: 22px; height: 22px; border: 1px solid #cfd6dc; border-radius: 6px; align-items: center; justify-content: center; background: #fff; margin: 0 2px; color: #2c6ecb; }
.entry-guide .glyph-dark { color: #2c3e50; }
.entry-guide .glyph svg { width: 15px; height: 15px; }
.entry-guide details { font-size: 0.88rem; }
.entry-guide details summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-sub); padding: 4px 2px; }
.entry-guide details summary::-webkit-details-marker { display: none; }
.entry-guide details[open] summary { margin-bottom: 10px; }
.entry-guide .sub-notes { margin: 0; padding-left: 1.1em; font-size: 0.82rem; color: var(--text-sub); line-height: 1.65; display: flex; flex-direction: column; gap: 6px; }
.entry-guide .foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 0.78rem; margin-top: 4px; }
.entry-guide hr.sep { border: none; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }

/* 「はじめかた」 */
/* 欄とボタンの並び方は、アプリと同じ共通の決まり(style.css の .field-row)。ここでは欄の見た目だけ */
.entry-guide .field-row input {
    padding: 12px 16px; border: 1.5px solid #aab2bd; border-radius: 24px; background: #fff; color: var(--text);
    font-size: 1rem; outline: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em;
}
.entry-guide .field-row input:focus { border-color: var(--color-main); box-shadow: 0 0 0 3px rgba(50,158,145,0.15); }
.entry-guide .field-msg { font-size: 0.8rem; min-height: 1.2em; margin: -4px 4px 0; }
.entry-guide .field-msg.ng { color: #c0392b; }
.entry-guide .field-msg.ok { color: var(--color-main-dark); }
.entry-guide .row-link {
    display: flex; align-items: center; gap: 12px; background: white; padding: 14px 16px; border-radius: 16px; height: auto; white-space: normal;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02); cursor: pointer; border: none; width: 100%; text-align: left; font-family: inherit; color: inherit; font-weight: normal;
}
.entry-guide .row-link b { display: block; font-size: 0.95rem; }
.entry-guide .row-link small { display: block; font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.entry-guide .row-link .chev { margin-left: auto; color: #bbb; }
.entry-guide .quiet-link .chev { --mark-size: 14px; vertical-align: -2px; margin-left: 1px; }
.entry-guide .quiet-link { background: none; border: none; color: var(--text-sub); font-size: 0.85rem; font-weight: normal; text-decoration: underline; cursor: pointer; align-self: center; font-family: inherit; padding: 6px; height: auto; }
.entry-guide .toast { position: fixed; left: 16px; right: 16px; bottom: calc(20px + var(--safe-bottom, 0px)); z-index: 5; background: #2c3e50; color: #fff; border-radius: 12px; padding: 10px 14px; font-size: 0.85rem; text-align: center; max-width: 440px; margin: 0 auto; }

/* 下から出るシート(「コードを持っていない方へ」) */
.entry-guide .sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
/* シートの高さの決まり(G41): 中身に合わせ、上限は画面の 88%。角の丸みはアプリのシートと同じ 24px */
.entry-guide .sheet { background: #fff; width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 10px 18px calc(24px + var(--safe-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; max-height: 88dvh; overflow-y: auto; }
.entry-guide .sheet > * { flex-shrink: 0; }
/* シートの見出し(アプリのシートと同じ形: 左に見出し、右上に［閉じる］。スワイプで閉じると思わせるつまみは置かない) */
.entry-guide .sheet-head { display: flex; align-items: center; gap: 8px; min-height: 40px; padding-top: 14px; }
.entry-guide .sheet-head h3 { flex: 1; margin: 0; }
.entry-guide .sheet-close { flex-shrink: 0; height: 32px; padding: 0 16px; border-radius: 16px; border: 1px solid #d1d8e0; background: transparent; color: var(--text-sub); font-size: 0.75rem; font-weight: 600; font-family: inherit; cursor: pointer; }
.entry-guide .sheet h3 { margin: 0; font-size: 1.1rem; }
.entry-guide .sheet p { margin: 0; font-size: 0.9rem; line-height: 1.7; }
.entry-guide .sheet p.hint { font-size: 0.8rem; }
