/******************************************************************************
 HAHU SKILL DESIGN SYSTEM
 Reusable Learning Components
******************************************************************************/

/* =========================================================
   SHARED LEARNING LAYOUT
   ========================================================= */

.learning-section {
    margin: 32px 0;
}

.learning-card {
    padding: clamp(20px, 4vw, 34px);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    box-shadow: 0 12px 30px rgba(20, 39, 70, .08);
}

.learning-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.learning-heading-icon {
    width: 48px;
    height: 48px;
    display: grid;
    flex: 0 0 48px;
    place-items: center;
    background: #fff2bb;
    border-radius: 15px;
    font-size: 1.5rem;
}

.learning-heading h2 {
    margin: 3px 0 0;
}

.learning-kicker {
    display: block;
    color: #7041bd;
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.learning-introduction {
    max-width: 850px;
    margin-bottom: 24px;
    color: var(--color-text-muted);
    line-height: 1.65;
}

.tracing-save-button:disabled {
    background: #a9b8c8;
    border-color: #a9b8c8;
    color: #f6f8fa;
    cursor: not-allowed;
    opacity: .7;
    transform: none;
    box-shadow: none;
}

/* =========================================================
   FIDEL FAMILY CARDS
   ========================================================= */

.fidel-family-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.fidel-family-card {
    min-width: 0;
    padding: 22px;
    background: #fff;
    border: 1px solid #dde5ef;
    border-left: 5px solid #7041bd;
    border-radius: 18px;
    box-shadow: 0 7px 18px rgba(30, 50, 80, .06);
}

.fidel-family-card.theme-purple {
    border-left-color: #7747d7;
    background: #fcf9ff;
}

.fidel-family-card.theme-green {
    border-left-color: #2eaa63;
    background: #f7fff9;
}

.fidel-family-card.theme-orange {
    border-left-color: #ef8b28;
    background: #fffaf5;
}

.fidel-family-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.fidel-family-header h3 {
    margin: 4px 0 0;
    font-size: 1.3rem;
}

.fidel-family-label {
    color: var(--color-text-muted);
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.fidel-family-icon {
    width: 48px;
    height: 48px;
    display: grid;
    flex: 0 0 48px;
    place-items: center;
    background: #eee7ff;
    border-radius: 14px;
    color: #7041bd;
    font-family: var(--font-ethiopic);
    font-size: 1.7rem;
    font-weight: 900;
}


/* =========================================================
   FIDEL TILES
   ========================================================= */

.fidel-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.fidel-tile {
    position: relative;
    min-width: 0;
    min-height: 78px;
    padding: 10px 6px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;

    background: #fff;
    border: 2px solid #d9e1ed;
    border-radius: 14px;
    color: #173d62;

    cursor: pointer;
    touch-action: manipulation;
    transition:
        transform .18s ease,
        border-color .18s ease,
        background .18s ease,
        box-shadow .18s ease;
}

.fidel-tile:hover {
    transform: translateY(-3px);
    border-color: #2b7cff;
    box-shadow: 0 9px 18px rgba(43, 124, 255, .13);
}

.fidel-tile:focus-visible {
    outline: 4px solid rgba(43, 124, 255, .25);
    outline-offset: 3px;
}

.fidel-tile.is-active {
    background: #e9f2ff;
    border-color: #2b7cff;
}

.fidel-tile.is-practiced::after {
    content: "✓";
    position: absolute;
    top: 5px;
    right: 7px;
    color: #198754;
    font-size: .75rem;
    font-weight: 900;
}

.fidel-character {
    font-family: var(--font-ethiopic);
    font-size: clamp(1.65rem, 3vw, 2.15rem);
    font-weight: 900;
    line-height: 1;
}

.fidel-speaker {
    font-size: .82rem;
    opacity: .72;
}

.fidel-family-status {
    min-height: 24px;
    margin: 15px 0 0;
    color: #456;
    font-size: .88rem;
    font-weight: 700;
}


/* =========================================================
   LEARNING PROGRESS
   ========================================================= */

.learning-progress-panel {
    margin-top: 24px;
    padding: 18px;
    background: #f7f9fc;
    border: 1px solid #e1e7ef;
    border-radius: 16px;
}

.learning-progress-panel > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 10px;
}

.learning-progress-track {
    height: 10px;
    overflow: hidden;
    background: #dfe5ec;
    border-radius: 999px;
}

.learning-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #2b7cff, #7041bd);
    border-radius: inherit;
    transition: width .3s ease;
}

/* =========================================================
   HANDWRITING TRACING PANEL
   Reusable across all modules
   ========================================================= */

.tracing-panel {
    margin-top: 30px;
    padding: clamp(20px, 4vw, 30px);

    background:
        linear-gradient(
            145deg,
            #fffdf8,
            #f7fbff
        );

    border: 1px solid #dfe7ef;
    border-radius: 20px;

    box-shadow:
        0 10px 24px rgba(30, 50, 80, .07);
}

.tracing-heading {
    margin-bottom: 12px;
}

.tracing-introduction {
    max-width: 820px;
    margin-bottom: 20px;

    color: var(--color-text-muted);
    line-height: 1.65;
}


/* Character selector */

.tracing-character-selector {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));

    gap: 10px;
    margin-bottom: 22px;
}

.tracing-character-button {
    min-width: 0;
    min-height: 56px;
    padding: 8px;

    display: grid;
    place-items: center;

    background: #fff;
    border: 2px solid #d9e1ed;
    border-radius: 12px;

    color: #173d62;

    font-family: var(--font-ethiopic);
    font-size: 1.55rem;
    font-weight: 900;

    cursor: pointer;
    touch-action: manipulation;

    transition:
        transform .18s ease,
        border-color .18s ease,
        background .18s ease,
        color .18s ease,
        box-shadow .18s ease;
}

.tracing-character-button:hover {
    transform: translateY(-2px);

    border-color: #7041bd;

    box-shadow:
        0 7px 15px rgba(112, 65, 189, .12);
}

.tracing-character-button:focus-visible {
    outline: 4px solid rgba(43, 124, 255, .24);
    outline-offset: 3px;
}

.tracing-character-button.is-selected {
    background: #7041bd;
    border-color: #7041bd;
    color: #fff;
}

.tracing-character-button.is-practiced::after {
    content: "✓";

    position: absolute;
    top: 3px;
    right: 6px;

    color: #16804b;
    font-size: .7rem;
    font-family: sans-serif;
    font-weight: 900;
}

.tracing-character-button {
    position: relative;
}


/* Workspace */

.tracing-workspace {
    max-width: 850px;
    margin-inline: auto;
}

.tracing-canvas-wrapper {
    position: relative;

    width: 100%;
    height: clamp(300px, 45vw, 460px);

    overflow: hidden;

    background:
        linear-gradient(
            rgba(43, 124, 255, .07) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(43, 124, 255, .07) 1px,
            transparent 1px
        ),
        #fff;

    background-size: 32px 32px;

    border: 3px solid #cad6e5;
    border-radius: 18px;

    touch-action: none;
    user-select: none;
}

.tracing-guide-character {
    position: absolute;
    inset: 0;

    display: grid;
    place-items: center;

    color: rgba(112, 65, 189, .15);

    font-family: var(--font-ethiopic);
    font-size: clamp(11rem, 28vw, 20rem);
    font-weight: 900;
    line-height: 1;

    pointer-events: none;
}

.tracing-canvas {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    cursor: crosshair;
    touch-action: none;
}


/* Toolbar */

.tracing-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;

    gap: 12px;
    margin-top: 16px;
}

.tracing-tool-button {
    min-height: 46px;
    padding: 10px 18px;

    background: #fff;
    border: 2px solid #cbd6e4;
    border-radius: 12px;

    color: #173d62;
    font-weight: 800;

    cursor: pointer;

    transition:
        transform .18s ease,
        border-color .18s ease,
        box-shadow .18s ease;
}

.tracing-tool-button:hover {
    transform: translateY(-2px);

    border-color: #2b7cff;

    box-shadow:
        0 7px 16px rgba(43, 124, 255, .12);
}

.tracing-save-button {
    background: #2b7cff;
    border-color: #2b7cff;
    color: #fff;
}

.tracing-status {
    min-height: 25px;
    margin: 14px 0 0;

    text-align: center;

    color: #41576b;
    font-weight: 750;
}


/* =========================================================
   TABLET / IPAD
   ========================================================= */

@media (min-width: 768px) and (max-width: 1024px) {

    .tracing-character-selector {
        grid-template-columns:
            repeat(7, minmax(0, 1fr));
    }

    .tracing-character-button {
        min-height: 64px;
        font-size: 1.75rem;
    }

    .tracing-canvas-wrapper {
        height: 440px;
    }

    .tracing-tool-button {
        min-height: 52px;
        padding: 12px 22px;
    }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {

    .tracing-character-selector {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));
    }

    .tracing-character-button {
        min-height: 58px;
    }

    .tracing-canvas-wrapper {
        height: 340px;
    }

    .tracing-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .tracing-tool-button {
        width: 100%;
    }
}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 390px) {

    .tracing-character-selector {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .tracing-canvas-wrapper {
        height: 300px;
    }
}

/* =========================================================
   TABLET / IPAD
   Applies automatically to every future module
   ========================================================= */

@media (min-width: 768px) and (max-width: 1024px) {

    .learning-card {
        padding: 28px;
    }

    .fidel-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .fidel-tile {
        min-height: 88px;
    }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {

    .learning-section {
        margin: 22px 0;
    }

    .learning-card,
    .fidel-family-card {
        padding: 18px;
    }

    .learning-heading {
        align-items: flex-start;
    }

    .fidel-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }

    .fidel-tile {
        min-height: 76px;
    }

    .learning-progress-panel > div:first-child {
        flex-direction: column;
        gap: 4px;
    }
}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 390px) {

    .fidel-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================================================
   SPEAKING PRACTICE
   ========================================================= */

.speaking-panel {
    margin-top: 30px;
    padding: clamp(20px, 4vw, 30px);

    background:
        linear-gradient(
            145deg,
            #f8fbff,
            #fffaf5
        );

    border: 1px solid #dfe7ef;
    border-radius: 20px;

    box-shadow:
        0 10px 24px rgba(30, 50, 80, .07);
}

.speaking-introduction {
    max-width: 820px;
    margin-bottom: 20px;

    color: var(--color-text-muted);
    line-height: 1.65;
}

.speaking-character-selector {
    display: grid;
    grid-template-columns:
        repeat(7, minmax(0, 1fr));

    gap: 10px;
    margin-bottom: 22px;
}

.speaking-character-button {
    position: relative;

    min-width: 0;
    min-height: 56px;
    padding: 8px;

    display: grid;
    place-items: center;

    background: #fff;
    border: 2px solid #d9e1ed;
    border-radius: 12px;

    color: #173d62;

    font-family: var(--font-ethiopic);
    font-size: 1.55rem;
    font-weight: 900;

    cursor: pointer;
    touch-action: manipulation;

    transition:
        transform .18s ease,
        border-color .18s ease,
        background .18s ease,
        color .18s ease;
}

.speaking-character-button:hover {
    transform: translateY(-2px);
    border-color: #2b7cff;
}

.speaking-character-button.is-selected {
    background: #2b7cff;
    border-color: #2b7cff;
    color: #fff;
}

.speaking-character-button.is-practiced::after {
    content: "✓";

    position: absolute;
    top: 3px;
    right: 6px;

    color: #16804b;
    font-family: sans-serif;
    font-size: .72rem;
    font-weight: 900;
}

.speaking-workspace {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 20px;
}

.speaking-model-card,
.speaking-recording-card {
    min-width: 0;
    padding: 24px;

    background: #fff;
    border: 1px solid #dfe6ee;
    border-radius: 18px;

    text-align: center;
}

.speaking-card-label {
    display: block;
    margin-bottom: 12px;

    color: var(--color-text-muted);
    font-size: .75rem;
    font-weight: 900;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.speaking-current-character {
    margin-bottom: 18px;

    color: #7041bd;

    font-family: var(--font-ethiopic);
    font-size: clamp(5rem, 10vw, 8rem);
    font-weight: 900;
    line-height: 1;
}

.speaking-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;

    gap: 10px;
}

.speaking-action-button {
    min-height: 46px;
    padding: 10px 16px;

    background: #fff;
    border: 2px solid #cad6e5;
    border-radius: 12px;

    color: #173d62;
    font-weight: 800;

    cursor: pointer;
}

.speaking-record-button {
    background: #e5484d;
    border-color: #e5484d;
    color: #fff;
}

.speaking-save-button {
    background: #2b7cff;
    border-color: #2b7cff;
    color: #fff;
}

.speaking-action-button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.speaking-recording-indicator {
    min-height: 34px;
    margin-bottom: 16px;

    display: inline-flex;
    align-items: center;
    gap: 9px;

    color: #526574;
    font-weight: 800;
}

.speaking-recording-indicator span {
    width: 11px;
    height: 11px;

    background: #9aa9b7;
    border-radius: 50%;
}

.speaking-recording-indicator.is-recording span {
    background: #e5484d;

    animation:
        speakingPulse 1s infinite;
}

.speaking-status {
    min-height: 26px;
    margin: 16px 0 0;

    color: #41576b;
    text-align: center;
    font-weight: 750;
}

@keyframes speakingPulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: .45;
    }
}


/* Tablet / iPad */

@media (min-width: 768px) and (max-width: 1024px) {

    .speaking-character-selector {
        grid-template-columns:
            repeat(7, minmax(0, 1fr));
    }

    .speaking-character-button {
        min-height: 64px;
        font-size: 1.75rem;
    }

    .speaking-action-button {
        min-height: 52px;
    }
}


/* Mobile */

@media (max-width: 767px) {

    .speaking-character-selector {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));
    }

    .speaking-workspace {
        grid-template-columns: 1fr;
    }

    .speaking-controls {
        display: grid;
        grid-template-columns: 1fr;
    }

    .speaking-action-button {
        width: 100%;
    }
}


/* Small mobile */

@media (max-width: 390px) {

    .speaking-character-selector {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }
}


