/* MediCalc - 共通スタイルシート（index / pages 用）
   カラーは css/tokens.css のデザイントークンを参照する */

/* リセット */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    font-size: 16px;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ヘッダー */
header {
    position: sticky;
    top: 0;
    z-index: 500;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text);
    min-height: 40px;
}

.logo img {
    height: 30px;
    width: auto;
    margin-right: 8px;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

/* ナビゲーション（pages/ で使用） */
nav ul {
    display: flex;
    list-style: none;
    gap: 2px;
    margin: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

nav a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    text-decoration: none;
    color: var(--text-2);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0 10px;
    border-radius: var(--radius-sm);
}

nav a:hover {
    background-color: var(--surface-3);
    color: var(--text);
}

nav a.active {
    color: var(--accent);
    font-weight: 700;
}

/* メインコンテンツ */
main {
    min-height: calc(100vh - 140px);
    padding: 1.25rem 0 2rem;
}

/* ============ ホーム: 検索 ============ */
.search-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
    display: flex;
}

.search-input {
    width: 100%;
    min-height: 52px;
    padding: 0 44px 0 42px;
    font-size: 16px; /* iOS の自動ズーム防止のため 16px 以上 */
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    -webkit-appearance: none;
    appearance: none;
}

.search-input::placeholder { color: var(--text-3); }

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    display: none;
}
.search-wrap.has-value .search-clear { display: block; }

/* ============ ホーム: 最近使用 ============ */
.recent-row {
    display: none;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.recent-row.visible { display: flex; }

.recent-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-3);
    flex-shrink: 0;
}

.recent-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.recent-chip:active { background: var(--surface-3); }

/* ============ ホーム: ツール一覧 ============ */
.tool-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 1.5rem;
    list-style: none;
}

.tool-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    min-height: var(--tap);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
}

.tool-row:hover {
    border-color: var(--accent);
}

.tool-row:active {
    background: var(--surface-2);
}

.tool-row.hidden { display: none; }

.tool-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 22px;
    background: var(--accent-soft);
    border-radius: 10px;
    flex-shrink: 0;
}

.tool-text { flex: 1; min-width: 0; }

.tool-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.35;
}

.tool-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-2);
    margin: 2px 0 0;
    line-height: 1.45;
}

.tool-chevron {
    color: var(--text-3);
    flex-shrink: 0;
    font-size: 18px;
}

.no-result {
    display: none;
    text-align: center;
    color: var(--text-2);
    padding: 2rem 1rem;
    font-size: 0.95rem;
}
.no-result.visible { display: block; }

/* ============ iOSアプリへの導線 ============ */
.app-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    margin: 1.25rem 0;
    background: var(--surface);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
}

.app-card:hover { border-color: var(--accent); }
.app-card:active { background: var(--surface-2); }

.app-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    flex-shrink: 0;
    object-fit: cover;
}

.app-card-text { flex: 1; min-width: 0; }

.app-card-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 4px;
    padding: 2px 6px;
    margin-bottom: 4px;
}

.app-card-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
}

.app-card-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-2);
    margin-top: 2px;
    line-height: 1.45;
}

.app-card-chevron {
    color: var(--text-3);
    flex-shrink: 0;
    font-size: 18px;
}

/* ============ 注意書き ============ */
.note-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    color: var(--warn-text);
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    line-height: 1.6;
}

/* ============ 開発テストページ ============ */
/* 検索フィルタ（.tool-row を対象とする）に含めないため、行は .dev-row とする */
.dev-section {
    margin: 2rem 0 0.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-strong);
}

.dev-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-2);
}

.dev-badge {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--warn-text);
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    border-radius: 4px;
    padding: 2px 6px;
    letter-spacing: 0.04em;
}

.dev-lead {
    margin: 0 0 0.9rem;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-3);
}

.dev-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.dev-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    min-height: var(--tap);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
}

.dev-row:hover { border-color: var(--accent); border-style: solid; }
.dev-row:active { background: var(--surface-2); }

/* ============ pages/ 用コンテンツ ============ */
.page-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.4rem;
    color: var(--text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* ボタン */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 1.5rem;
    background-color: var(--accent);
    color: var(--on-accent);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn:hover { background-color: var(--accent-strong); }

.btn-primary { background-color: var(--accent); }
.btn-accent { background-color: var(--accent); }

/* フッター */
footer {
    border-top: 1px solid var(--border);
    color: var(--text-2);
    padding: 1.5rem 0 max(1.5rem, env(safe-area-inset-bottom));
    margin-top: 1rem;
    font-size: 0.85rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.footer-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    flex-wrap: wrap;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 10px;
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.footer-links a:hover {
    color: var(--accent);
    background: var(--surface-3);
}

/* レスポンシブ */
@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .page-content { padding: 1.25rem 1rem; }
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    nav a { font-size: 0.8rem; padding: 0 8px; }
}

/* 印刷 */
@media print {
    header,
    footer,
    nav,
    .search-wrap,
    .recent-row {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .page-content {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
