/* Card layout
   Fonts: Figtree (EN) + Noto Sans JP (JA) — chosen for clarity under stress
*/

@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    --blue-dark:   #1a3a5c;
    --blue-mid:    #2a5a8c;
    --blue-light:  #eef4fb;
    --blue-border: #b0cce8;
    --red:         #c0392b;
    --green:       #2e7d32;
    --highlight:   #ffe566;
    --highlight-bg: #fffbe6;
    --ja-bg:       #fafaf8;
    --border:      #e4e4e0;
    --text:        #111;
    --text-muted:  #666;
    --radius:      14px;
    --font-en:     'Figtree', -apple-system, sans-serif;
    --font-ja:     'Noto Sans JP', sans-serif;
}

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

body {
    font-family: var(--font-en);
    background: #f0f0ec;
    margin: 0;
    padding: 0;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ── Nav ─────────────────────────────────────────────────── */

header nav {
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}

header nav a {
    text-decoration: none;
    color: var(--red);
    font-weight: 700;
}

/* ── Page wrapper ────────────────────────────────────────── */

.card-page {
    max-width: 680px;
    margin: 0 auto;
    padding: 20px 14px 48px;
}

/* ── Invite layer ────────────────────────────────────────── */

.invite-layer {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(238, 244, 251, 0.92);
    z-index: 200;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.invite-layer.dimming { opacity: 0.4; }
.invite-layer.gone    { opacity: 0; }

.invite-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--blue-dark);
    text-align: center;
    padding: 32px;
    line-height: 1.5;
}

/* ── Context banner ──────────────────────────────────────── */

@keyframes banner-slide-up {
    from { top: 58px; }
    to   { top: 0px;  }
}

.context-banner {
    background: var(--blue-light);
    border: 2px solid var(--blue-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-align: center;
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    z-index: 100;
    transition: padding 0.2s ease;
    animation: banner-slide-up linear both;
    animation-timeline: scroll();
    animation-range: 0px 58px;
}

.context-banner.compact { padding: 8px 20px; }

.context-banner.compact .context-banner-trust,
.context-banner.compact .context-banner-en,
.context-banner.compact .context-banner-ja { display: none; }

.context-banner-compact-label {
    display: none;
    font-family: var(--font-ja);
    font-size: 17px;
    font-weight: 700;
    color: var(--blue-dark);
}

.context-banner.compact .context-banner-compact-label { display: block; }

.context-banner-ja {
    font-family: var(--font-ja);
    font-size: 17px;
    font-weight: 700;
    color: var(--blue-dark);
    margin-bottom: 6px;
}

.context-banner-trust {
    font-family: var(--font-ja);
    font-size: 13px;
    color: var(--blue-mid);
    margin-bottom: 6px;
}

.context-banner-en {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Clinic header ───────────────────────────────────────── */

.clinic-header {
    text-align: center;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.clinic-add-btn {
    background: none;
    border: 1px dashed #bbb;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    color: #999;
    cursor: pointer;
    font-family: var(--font-en);
}

.clinic-header input {
    padding: 6px 13px;
    font-size: 15px;
    border: 2px solid var(--blue-border);
    border-radius: 10px;
    outline: none;
    flex: 1;
    max-width: 220px;
    font-family: var(--font-en);
}

.clinic-header button#clinic-save {
    padding: 6px 13px;
    background: var(--blue-dark);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font-en);
}

.clinic-link {
    display: inline-block;
    font-size: 15px;
    font-weight: 600;
    color: var(--blue-dark);
    text-decoration: none;
    background: var(--blue-light);
    border: 1px solid var(--blue-border);
    border-radius: 20px;
    padding: 6px 16px;
}

/* ── Card title ──────────────────────────────────────────── */

.card-title {
    margin-bottom: 20px;
    text-align: center;
}

.card-title-en {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.card-title-ja {
    display: block;
    font-family: var(--font-ja);
    font-size: 20px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Card grid ───────────────────────────────────────────── */

.card-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Card ────────────────────────────────────────────────── */

.card {
    background: #fff;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── Card header (label row) ─────────────────────────────── */

.card-header {
    display: flex;
    border-bottom: 1.5px solid var(--border);
    background: #fafafa;
}

.card-label {
    flex: 1;
    padding: 13px 16px 9px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #999;
}

.card-label.en-label {
    border-right: 1.5px solid var(--border);
}

.card-label.ja-label {
    font-family: var(--font-ja);
    font-size: 12px;
}

.card-highlight .card-label {
    color: var(--red);
}

.card-doctor .card-label {
    color: var(--green);
    font-size: 12px;
}

/* ── Card body ───────────────────────────────────────────── */

.card-body {
    /* contains tap-items */
}

/* ── Tap items — mobile default: stacked pair ────────────── */

.tap-item {
    border-bottom: 1.5px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
}

.tap-item:last-child {
    border-bottom: none;
}

.item-en {
    display: block;
    padding: 14px 16px 10px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.4;
    color: var(--text);
    border-bottom: 1px solid #f0f0ec;
}

.item-ja {
    display: block;
    padding: 10px 16px 14px;
    font-family: var(--font-ja);
    font-size: 21px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text);
    background: var(--ja-bg);
    white-space: pre-line;
}

/* ── Tap items — wide: side-by-side ──────────────────────── */

@media (min-width: 580px) {
    .tap-item {
        display: flex;
        align-items: stretch;
    }

    .item-en {
        flex: 1;
        padding: 14px 18px;
        border-bottom: none;
        border-right: 1.5px solid var(--border);
    }

    .item-ja {
        flex: 1;
        padding: 14px 18px;
    }
}

/* ── Highlight ───────────────────────────────────────────── */

.tap-item.highlighted .item-en,
.tap-item.highlighted .item-ja {
    background: var(--highlight-bg);
    font-weight: 600;
}

.tap-item.highlighted .item-en {
    border-left: 3px solid var(--highlight);
}

@keyframes tap-pulse {
    0%   { background: var(--highlight-bg); }
    30%  { background: #fff0a0; }
    60%  { background: var(--highlight-bg); }
    100% { background: var(--highlight-bg); }
}

.tap-item.pulsing .item-en,
.tap-item.pulsing .item-ja {
    animation: tap-pulse 0.7s ease-out;
}

/* ── Dismissed ───────────────────────────────────────────── */

.tap-item.dismissed .item-en,
.tap-item.dismissed .item-ja {
    opacity: 0.4;
    text-decoration: line-through;
    text-decoration-color: var(--blue-mid);
}

/* ── Changeable / editable ───────────────────────────────── */

.changeable-opt {
    display: inline-block;
    margin: 3px 5px 3px 0;
    padding: 6px 13px;
    border: 1.5px solid var(--blue-border);
    border-radius: 20px;
    background: #fff;
    font-size: 15px;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
}

.changeable-edit-hint {
    font-size: 12px;
    opacity: 0.6;
}

.changeable-opt.current {
    background: var(--blue-light);
    border-color: var(--blue-mid);
    font-weight: 600;
}

.item-en .card-text.editable,
.item-ja .card-text.editable {
    border-bottom: 1px dashed #ccc;
    outline: none;
    min-height: 24px;
}

/* ── Furigana ────────────────────────────────────────────── */

rt {
    display: none;
    font-size: 11px;
    color: #888;
    font-family: var(--font-ja);
}

body.learning-mode rt { display: revert; }

.furigana-toggle {
    display: block;
    margin: 28px auto 16px;
    font-size: 13px;
    background: none;
    border: 1px solid var(--blue-border);
    border-radius: 20px;
    padding: 6px 18px;
    cursor: pointer;
    color: var(--blue-dark);
    font-family: var(--font-en);
}

.furigana-toggle.on { background: var(--blue-light); }

/* ── Footer ──────────────────────────────────────────────── */

footer {
    text-align: center;
    padding: 32px;
    color: #bbb;
    font-size: 13px;
}
