/* ==========================================================
   Japan.app – global styles
   Theme tokens, base elements, loading and error screens.
   Component styles live next to their components (*.razor.css).
   ========================================================== */

/* ---------- Theme tokens ----------
   Light is the default. data-theme="dark" on <html> switches the whole app;
   data-theme="light" on an element (e.g. the show screen) forces light inside it. */

:root,
[data-theme="light"] {
    color-scheme: light;
    --ground: #F7F5F0;
    --surface: #FFFFFF;
    --ink: #1C1B1A;
    --muted: #5F5B54;
    --line: #DEDAD2;
    --mark-idle: #CFCAC0;
    --info: #F4F2EE;
    --active: #E7E3DA;
    --indigo: #2B4C9B;
    --indigo-text: #2B4C9B;
    --indigo-soft: #EDF1FA;
    --shu: #B8391A;
    --shu-soft: #FBEEE9;
    --primary-button: #1C1B1A;
    --primary-button-text: #FFFFFF;
    --primary-button-off: #8A857C;
    --badge: rgba(255, 255, 255, 0.2);
    --overlay: rgba(28, 27, 26, 0.45);
}

[data-theme="dark"] {
    color-scheme: dark;
    --ground: #161514;
    --surface: #201F1D;
    --ink: #F2EFE9;
    --muted: #A8A398;
    --line: #34322E;
    --mark-idle: #4A4741;
    --info: #2A2926;
    --active: #2E2C29;
    --indigo: #5B7BD5;
    --indigo-text: #A9BCF0;
    --indigo-soft: #1E2740;
    --shu: #D9583A;
    --shu-soft: #3A221B;
    --primary-button: #F2EFE9;
    --primary-button-text: #161514;
    --primary-button-off: #5C5952;
    --badge: rgba(0, 0, 0, 0.12);
    --overlay: rgba(0, 0, 0, 0.6);
}

/* Theme-independent tokens. System fonts only: no download, works offline, native look. */
:root {
    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", Meiryo, sans-serif;
    --font-ja: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", Meiryo, sans-serif;
    --radius-card: 16px;
    --radius-control: 12px;
    --tap-size: 44px;
    --app-width: 480px;
    /* Height of the app area: the screen on phones, the frame on desktop (MainLayout.razor.css). */
    --app-height: 100dvh;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.4;
}

:lang(ja) {
    font-family: var(--font-ja);
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

a {
    color: inherit;
}

/* Classes with their own display value would otherwise override the hidden attribute. */
[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--indigo);
    outline-offset: 2px;
}

/* Headings only receive focus programmatically (FocusOnNavigate) so screen readers announce the new page; no frame needed. */
h1:focus {
    outline: none;
}

/* ---------- Loading screen (index.html, before Blazor renders) ---------- */

.startup {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22vh 24px 0;
    text-align: center;
}

.startup__logo {
    border-radius: 16px;
}

.startup__name {
    margin: 16px 0 0;
    font-size: 24px;
    font-weight: 700;
}

.startup__tagline {
    margin: 4px 0 28px;
    color: var(--muted);
}

.loading-progress {
    display: block;
    width: 3rem;
    height: 3rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--line);
    stroke-width: 0.3rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--indigo);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ---------- Unhandled error banner (index.html) ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 1rem 3rem 1rem 1.25rem;
    background: var(--shu-soft);
    color: var(--ink);
    border-top: 2px solid var(--shu);
}

#blazor-error-ui .reload {
    font-weight: 700;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    cursor: pointer;
}

/* ---------- Error fallback of the ErrorBoundary in MainLayout ---------- */

.app-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 20vh 1.5rem 0;
    text-align: center;
}

.app-error__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.app-error__text {
    margin: 0;
    color: var(--muted);
}

.app-error__button {
    min-height: 48px;
    padding: 0 1.5rem;
    border: 0;
    border-radius: var(--radius-control);
    background: var(--primary-button);
    color: var(--primary-button-text);
    font-weight: 600;
}

/* ---------- Item cards: shared base of the rows on a category screen (ToggleRow, CounterRow, ChoiceRow) ---------- */

.item-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 64px;
    padding: 10px 12px 10px 14px;
    border: 2px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
    color: var(--ink);
    text-align: left;
}

.item-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
}

.item-card__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.item-card__label {
    font-size: 18px;
    font-weight: 600;
}

.item-card__hint {
    font-size: 13px;
    color: var(--muted);
}

.item-card__tip {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--muted);
}
