/* Kaizou-Scratch site styles */

:root {
    --purple: #855CD6;
    --purple-dark: #6D45B8;
    --purple-light: #F3EBFF;
    --green: #4D9D74;
    --orange: #FCBD3D;
    --orange-dark: #F2A23C;
    --text: #4D4D4D;
    --text-soft: #6B6B73;
    --border: #E5E5EA;
    --bg: #F7F7FA;
    --card: #FFFFFF;
    --shadow: 0 2px 10px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Meiryo", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header (editor menu-bar style) ---------- */

.kz-header {
    background: var(--purple);              /* #855CD6 — same as the editor menu bar */
    color: white;
    height: 3rem;                           /* 48px, like $menu-bar-height */
    padding: 0 0.25rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 0.75rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

@font-face {
    font-family: 'ScratchFont';            /* the Scratch wordmark typeface (Scratch.ttf) */
    src: url('/img/Scratch.ttf') format('truetype');
    font-display: swap;
}

.kz-logo {
    display: inline-flex;
    align-items: center;
    height: 100%;
    padding: 0 0.5rem;
    user-select: none;
}
.kz-logo img {
    height: 1.6rem;
    display: block;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18));
}
.kz-logo-text {
    font-family: 'ScratchFont', 'Helvetica Neue', Arial, sans-serif;
    color: #FF5247;
    font-size: 1.55rem;
    line-height: 1;
    margin-left: 0.45rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.22);
}
.kz-logo:hover { text-decoration: none; filter: brightness(1.06); }

.kz-mb-divider {
    width: 1px;
    height: 1.5rem;
    background: rgba(255,255,255,0.25);
    margin: 0 0.25rem;
    flex: none;
}

.kz-mb-nav {
    display: flex;
    align-items: center;
    height: 100%;
    flex: 1;
}

.kz-mb-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 100%;
    padding: 0 0.75rem;
    color: white;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.kz-mb-item:hover { background: hsla(0, 0%, 0%, 0.15); text-decoration: none; }
.kz-mb-item.active { background: hsla(0, 0%, 0%, 0.15); }
.kz-mb-item img { height: 1rem; width: auto; display: block; }

.kz-search {
    flex: 0 1 280px;
    position: relative;
    margin: 0 0.5rem;
}
.kz-search input {
    width: 100%;
    background: white;
    border: 0;
    border-radius: 9999px;
    padding: 7px 14px 7px 32px;
    font-size: 13px;
    font-weight: normal;
    color: var(--text);
}
.kz-search::before {
    content: "🔍";
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    opacity: 0.5;
}

.kz-icon-btn {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    border-radius: 6px;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    flex: none;
}
.kz-icon-btn:hover { background: hsla(0, 0%, 0%, 0.15); }
.kz-icon-btn svg { width: 20px; height: 20px; }

.kz-account-slot {
    display: inline-flex;
    align-items: center;
    margin-right: 0.25rem;
}

.kz-account {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    padding: 4px 10px 4px 4px;
    border-radius: 9999px;
    background: rgba(255,255,255,0.1);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.kz-account:hover { background: rgba(255,255,255,0.2); text-decoration: none; }
.kz-account .kz-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--orange);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: white;
    font-size: 13px;
}

/* Login / register buttons sized to fit the 48px bar */
.kz-header .kz-btn {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 700;
}

.kz-btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 9999px;
    background: var(--orange);
    color: white;
    font-weight: 700;
    border: 0;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}
.kz-btn:hover { background: var(--orange-dark); text-decoration: none; }
.kz-btn.kz-btn-ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.5); }
.kz-btn.kz-btn-ghost:hover { background: rgba(255,255,255,0.15); }
.kz-btn.kz-btn-secondary { background: white; color: var(--purple); }
.kz-btn.kz-btn-secondary:hover { background: var(--purple-light); }
.kz-btn.kz-btn-danger { background: #E04A4A; }

/* ---------- Layout ---------- */

.kz-container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 24px;
}

.kz-card {
    background: var(--card);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

/* ---------- Home banner ---------- */

.kz-banner {
    background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
    color: white;
    padding: 64px 32px;
    text-align: center;
    border-radius: 12px;
    margin-bottom: 32px;
}
.kz-banner h1 {
    font-size: 36px;
    margin: 0 0 12px;
    font-weight: 800;
}
.kz-banner p {
    font-size: 16px;
    margin: 0 0 24px;
    opacity: 0.9;
}
.kz-banner .kz-btn {
    background: var(--orange);
    font-size: 16px;
    padding: 12px 32px;
}

/* ---------- Hero section ---------- */

.kz-hero {
    text-align: center;
    padding: 40px 24px;
    background: white;
    border-radius: 12px;
    margin-bottom: 24px;
}
.kz-hero h2 {
    font-size: 24px;
    margin: 0 0 8px;
}
.kz-hero p {
    color: var(--text-soft);
    margin: 0;
}

/* ---------- Project grid ---------- */

.kz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.kz-project-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: transform 0.1s;
}
.kz-project-card:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}
.kz-project-card .kz-thumb {
    aspect-ratio: 4 / 3;
    background: #f0f0f5 center / cover no-repeat;
    border-bottom: 1px solid var(--border);
}
.kz-project-card .kz-meta {
    padding: 12px;
}
.kz-project-card .kz-title {
    font-weight: 600;
    color: var(--purple);
    margin: 0 0 4px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kz-project-card .kz-owner {
    color: var(--text-soft);
    font-size: 12px;
}

.kz-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-soft);
}

/* ---------- Forms ---------- */

.kz-form {
    max-width: 380px;
    margin: 48px auto;
    background: white;
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.kz-form h1 {
    margin: 0 0 24px;
    text-align: center;
    font-size: 22px;
    color: var(--purple);
}
.kz-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
    margin: 16px 0 6px;
}
.kz-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
}
.kz-form input:focus {
    outline: none;
    border-color: var(--purple);
}
.kz-form button {
    width: 100%;
    margin-top: 24px;
    padding: 12px;
    background: var(--purple);
    color: white;
    border: 0;
    border-radius: 6px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.kz-form button:hover { background: var(--purple-dark); }
.kz-form button:disabled { opacity: 0.5; cursor: wait; }
.kz-form .kz-alt {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-soft);
}
.kz-form .kz-error {
    background: #fdecec;
    color: #C0392B;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 12px;
    display: none;
}
.kz-form .kz-error.show { display: block; }

/* ---------- My-stuff list ---------- */

.kz-list-page {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    margin: 24px auto;
    max-width: 1100px;
    padding: 0 24px;
}
.kz-side {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    height: fit-content;
}
.kz-side a {
    display: block;
    padding: 12px 16px;
    color: var(--text);
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.kz-side a:last-child { border-bottom: 0; }
.kz-side a.active {
    background: var(--purple-light);
    color: var(--purple-dark);
    font-weight: 600;
    text-decoration: none;
}
.kz-side a:hover { background: var(--purple-light); text-decoration: none; }
.kz-side h3 {
    margin: 0;
    padding: 14px 16px;
    background: var(--purple);
    color: white;
    font-size: 14px;
}

.kz-list-main {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 16px;
}
.kz-list-main .kz-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.kz-list-main h2 { margin: 0; font-size: 18px; }

.kz-list-row {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.kz-list-row:last-child { border-bottom: 0; }
.kz-list-row .kz-thumb-sm {
    width: 120px;
    aspect-ratio: 4 / 3;
    background: #f0f0f5 center / cover no-repeat;
    border-radius: 4px;
    border: 1px solid var(--border);
}
.kz-list-row .kz-row-meta h3 {
    margin: 0 0 4px;
    font-size: 16px;
    color: var(--purple);
}
.kz-list-row .kz-row-meta h3 a { color: inherit; }
.kz-list-row .kz-row-meta p {
    margin: 0;
    font-size: 12px;
    color: var(--text-soft);
}
.kz-list-row .kz-row-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
}
.kz-list-row .kz-row-actions .kz-btn {
    font-size: 12px;
    padding: 5px 10px;
    text-align: center;
    background: var(--orange);
}
.kz-list-row .kz-row-actions .kz-btn.kz-btn-ghost {
    background: white;
    color: var(--text-soft);
    border: 1px solid var(--border);
}
.kz-list-row .kz-row-actions .kz-btn.kz-btn-ghost:hover { background: var(--purple-light); color: var(--purple); }
.kz-list-row .kz-row-actions .kz-btn.kz-btn-danger { background: transparent; color: #C0392B; border: 1px solid #E5BFBF; }
.kz-list-row .kz-row-actions .kz-btn.kz-btn-danger:hover { background: #fdecec; }

/* ---------- Project viewer ---------- */

.kz-viewer {
    max-width: 980px;
    margin: 24px auto;
    padding: 0 24px;
}
.kz-viewer h1 {
    margin: 0 0 8px;
    font-size: 24px;
}
.kz-viewer .kz-byline {
    color: var(--text-soft);
    font-size: 14px;
    margin-bottom: 16px;
}
.kz-player-wrap {
    background: black;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.kz-player-wrap iframe {
    width: 100%;
    height: 480px;
    border: 0;
    display: block;
    background: black;
}
.kz-viewer .kz-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- Loading overlay ---------- */

.kz-loading {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.kz-loading.show {
    opacity: 1;
    pointer-events: auto;
}
.kz-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid var(--purple-light);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: kz-spin 0.8s linear infinite;
}
@keyframes kz-spin {
    to { transform: rotate(360deg); }
}
.kz-loading .kz-loading-text {
    color: var(--purple-dark);
    font-weight: 600;
    font-size: 14px;
}

/* ---------- Misc ---------- */

.kz-tag {
    display: inline-block;
    background: var(--purple-light);
    color: var(--purple-dark);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kz-tag.kz-tag-shared { background: #DDF2E5; color: var(--green); }

.kz-hidden { display: none !important; }
