/*
 * ACE Sentence Table
 * Selector, summary, and multilingual flashcard styles.
 */

:root {
    --ace-bg: #f3f6fb;
    --ace-surface: #ffffff;
    --ace-text: #172033;
    --ace-muted: #64748b;
    --ace-border: #d9e1ec;
    --ace-primary: #1d4ed8;
    --ace-primary-dark: #1e3a8a;
    --ace-primary-soft: #eff6ff;
    --ace-accent: #b7791f;
    --ace-success: #166534;
    --ace-danger-bg: #fff1f2;
    --ace-danger: #9f1239;
    --ace-radius: 14px;
    --ace-shadow: 0 12px 34px rgba(15, 23, 42, 0.10);
}

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

body {
    margin: 0;
    background: var(--ace-bg);
    color: var(--ace-text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

.ace-page {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto 56px;
}

.ace-header {
    padding: 28px 30px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--ace-primary-dark), var(--ace-primary));
    border-radius: var(--ace-radius) var(--ace-radius) 0 0;
    box-shadow: var(--ace-shadow);
}

.ace-header h1 {
    margin: 0 0 6px;
    font-size: clamp(1.65rem, 3vw, 2.25rem);
    line-height: 1.2;
}

.ace-header p {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
}

.ace-record-info {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 12px;
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.ace-record-info [dir="rtl"] {
    font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, serif;
    font-size: 1.2em;
}

.ace-selector {
    padding: 24px 26px;
    background: var(--ace-surface);
    border-right: 1px solid var(--ace-border);
    border-bottom: 1px solid var(--ace-border);
    border-left: 1px solid var(--ace-border);
}

.ace-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: end;
}

.ace-control {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
    color: #334155;
    font-size: 0.9rem;
    font-weight: 700;
}

.ace-control select,
.ace-control button {
    width: 100%;
    min-height: 46px;
    border-radius: 9px;
    font: inherit;
}

.ace-control select {
    padding: 9px 38px 9px 12px;
    color: var(--ace-text);
    background-color: #ffffff;
    border: 1px solid #bcc8d8;
    font-weight: 500;
    cursor: pointer;
}

.ace-control select:hover:not(:disabled) {
    border-color: #7c94b5;
}

.ace-control select:focus-visible,
.ace-control button:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}

.ace-control select:disabled {
    color: #64748b;
    background: #eef2f7;
    border-style: dashed;
    cursor: not-allowed;
    opacity: 1;
}

.ace-control-button button {
    padding: 10px 18px;
    color: #ffffff;
    background: var(--ace-primary);
    border: 1px solid var(--ace-primary);
    box-shadow: 0 5px 12px rgba(29, 78, 216, 0.20);
    font-weight: 750;
    cursor: pointer;
    transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.ace-control-button button:hover {
    background: var(--ace-primary-dark);
    box-shadow: 0 7px 16px rgba(29, 78, 216, 0.27);
    transform: translateY(-1px);
}

.ace-control-button button:active {
    transform: translateY(0);
}

.ace-selection-summary {
    padding: 15px 22px;
    color: #334155;
    background: var(--ace-primary-soft);
    border-right: 1px solid #bfdbfe;
    border-bottom: 1px solid #bfdbfe;
    border-left: 1px solid #bfdbfe;
    font-size: 0.95rem;
    text-align: center;
}

.ace-address {
    display: inline-block;
    padding: 3px 9px;
    color: var(--ace-primary-dark);
    background: #ffffff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 800;
    letter-spacing: 0.035em;
}

.ace-focused-display {
    display: grid;
    place-items: center;
    padding: clamp(28px, 5vw, 58px) 18px;
}

.ace-card {
    position: relative;
    width: min(780px, 100%);
    min-height: 390px;
    overflow: hidden;
    padding: 72px clamp(24px, 6vw, 62px) 34px;
    background: var(--ace-surface);
    border: 1px solid var(--ace-border);
    border-top: 6px solid var(--ace-accent);
    border-radius: 18px;
    box-shadow: var(--ace-shadow);
    text-align: center;
}

.ace-card-address {
    position: absolute;
    top: 18px;
    right: 20px;
    padding: 5px 10px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid var(--ace-border);
    border-radius: 999px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 750;
}

.ace-card-title {
    margin-bottom: 27px;
    color: var(--ace-primary-dark);
    font-size: clamp(1.15rem, 2.5vw, 1.45rem);
    font-weight: 800;
    letter-spacing: 0.015em;
}

.ace-arabic,
.ace-urdu {
    overflow-wrap: anywhere;
    text-align: center;
}

.ace-arabic {
    margin: 0 0 23px;
    color: #111827;
    font-family: "Noto Naskh Arabic", "Scheherazade New", "Traditional Arabic", serif;
    font-size: clamp(2.25rem, 6vw, 4rem);
    font-weight: 600;
    line-height: 1.75;
}

.ace-meaning {
    margin: 0 auto 21px;
    color: var(--ace-success);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.35rem, 3.2vw, 2rem);
    font-weight: 650;
    line-height: 1.45;
}

.ace-urdu {
    margin: 0;
    color: #6b3f10;
    font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", "Segoe UI", serif;
    font-size: clamp(1.45rem, 3.8vw, 2.25rem);
    line-height: 2;
}

.ace-empty {
    margin: 30px auto;
    padding: 18px 20px;
    color: var(--ace-danger);
    background: var(--ace-danger-bg);
    border: 1px solid #fecdd3;
    border-radius: 10px;
    font-weight: 700;
}

.ace-card-fields {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.ace-card-fields span {
    padding: 4px 8px;
    color: var(--ace-muted);
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
}

@media (max-width: 850px) {
    .ace-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .ace-page {
        width: min(100% - 18px, 1180px);
        margin-top: 10px;
    }

    .ace-header,
    .ace-selector {
        padding: 20px 17px;
    }

    .ace-controls {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .ace-selection-summary {
        line-height: 1.9;
        text-align: left;
    }

    .ace-focused-display {
        padding: 25px 0;
    }

    .ace-card {
        min-height: 340px;
        padding: 68px 20px 27px;
        border-radius: 13px;
    }

    .ace-card-address {
        top: 15px;
        right: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ace-control-button button {
        transition: none;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .ace-page {
        width: 100%;
        margin: 0;
    }

    .ace-selector,
    .ace-selection-summary {
        display: none;
    }

    .ace-header,
    .ace-card {
        color: #000000;
        background: #ffffff;
        border: 1px solid #999999;
        box-shadow: none;
    }

    .ace-header p,
    .ace-header .ace-record-info {
        color: #222222;
    }
}
/* =========================================================
   ACE Grammar Engine monogram
   ========================================================= */

.ace-flashcard,
.flashcard {
    position: relative;
}

.ace-monogram {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;

    display: grid;
    grid-template-columns: 44px auto;
    grid-template-rows: auto auto;
    column-gap: 9px;
    align-items: center;

    min-width: 132px;
    padding: 7px 11px 7px 8px;

    color: #f7e9b7;
    background:
        linear-gradient(145deg, #183e34, #0b241f);
    border: 1px solid rgba(212, 175, 55, 0.75);
    border-radius: 12px;
    box-shadow:
        0 5px 14px rgba(0, 0, 0, 0.18),
        inset 0 0 0 1px rgba(255, 255, 255, 0.06);

    font-family: Georgia, "Times New Roman", serif;
    line-height: 1;
    user-select: none;
}

.ace-monogram-arabic {
    grid-column: 1;
    grid-row: 1 / 3;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;

    color: #173b32;
    background: linear-gradient(145deg, #f6df91, #c99b2c);
    border-radius: 50%;

    font-family: "Noto Naskh Arabic", "Amiri", serif;
    font-size: 27px;
    font-weight: 700;
    line-height: 42px;
    text-align: center;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.25),
        inset 0 1px 1px rgba(255, 255, 255, 0.55);
}

.ace-monogram-name {
    grid-column: 2;
    grid-row: 1;

    color: #f8e7a8;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.ace-monogram-subtitle {
    grid-column: 2;
    grid-row: 2;

    margin-top: 3px;
    color: rgba(255, 255, 255, 0.78);
    font-family: Arial, sans-serif;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Keep flashcard content clear of the monogram. */
.ace-flashcard,
.flashcard {
    padding-top: 82px;
}

@media (max-width: 600px) {
    .ace-monogram {
        position: relative;
        top: auto;
        right: auto;
        width: max-content;
        margin: 0 auto 18px;
    }

    .ace-flashcard,
    .flashcard {
        padding-top: 24px;
    }
}