/* Everyday Programming -- additions on top of the jekyll-gitbook theme.
 *
 * Scoped to classes this site introduces, so nothing here can drift when the
 * remote theme updates. Colors follow the printed book: the violet of its
 * drop capitals and the dark red of its hyperlinks.
 *
 * Sizes are in em, never rem. GitBook's stylesheet sets html{font-size:62.5%}
 * so that its own values can be written as round numbers -- which makes 1rem
 * ten pixels, not sixteen. Anything specified in rem here would come out at
 * about five-eighths of its intended size, so every length is relative to the
 * inherited font size instead.
 */

:root {
    --ep-violet: #5b21b6;
    --ep-violet-soft: #ede9fe;
    --ep-ink: #1f2328;
    --ep-muted: #57606a;
    --ep-rule: #d8dee4;
    --ep-tint: #f6f8fa;
}

/* ---------------------------------------------------------------- hero --- */

.ep-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 2em;
    align-items: flex-start;
    margin: 0 0 2.5em;
}

.ep-hero__cover {
    flex: 0 0 240px;
    max-width: 240px;
}

.ep-hero__cover img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--ep-rule);
    border-radius: 3px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}

.ep-hero__body {
    flex: 1 1 320px;
    min-width: 0;
}

.ep-hero__body > :first-child {
    margin-top: 0;
}

/* The IntuitAI logo in the landing page hero. Deliberately not __cover: that
 * one is sized for a book jacket and carries a border and drop shadow, which
 * around a transparent PNG would frame a box of empty space. */
.ep-hero__logo {
    flex: 0 0 120px;
    max-width: 120px;
}

.ep-hero__logo img {
    width: 100%;
    height: auto;
    display: block;
}

.ep-tagline {
    font-size: 1.2em;
    line-height: 1.5;
    color: var(--ep-ink);
}

.ep-kicker {
    display: inline-block;
    font-size: 0.75em;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--ep-violet);
    background: var(--ep-violet-soft);
    border-radius: 999px;
    padding: 0.25em 0.85em;
    margin-bottom: 0.9em;
}

/* ------------------------------------------------------------- buttons --- */

.ep-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em;
    margin: 1.4em 0 0;
}

.ep-btn,
a.ep-btn {
    display: inline-block;
    padding: 0.55em 1.15em;
    border-radius: 5px;
    border: 1px solid var(--ep-violet);
    font-size: 0.94em;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

a.ep-btn--primary {
    background: var(--ep-violet);
    color: #fff;
}

a.ep-btn--primary:hover {
    background: #4c1d95;
    color: #fff;
    text-decoration: none;
}

a.ep-btn--ghost {
    background: transparent;
    color: var(--ep-violet);
}

a.ep-btn--ghost:hover {
    background: var(--ep-violet-soft);
    text-decoration: none;
}

/* --------------------------------------------------------------- facts --- */

.ep-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1em;
    margin: 2em 0;
    padding: 0;
    list-style: none;
}

.ep-facts li {
    background: var(--ep-tint);
    border: 1px solid var(--ep-rule);
    border-radius: 6px;
    padding: 0.9em 1em;
    list-style: none;
}

.ep-facts b {
    display: block;
    font-size: 1.5em;
    line-height: 1.15;
    color: var(--ep-violet);
}

.ep-facts span {
    display: block;
    font-size: 0.85em;
    color: var(--ep-muted);
    margin-top: 0.15em;
}

/* ------------------------------------------------------- contents list --- */

.ep-toc {
    margin: 1.5em 0 0;
}

.ep-toc__part {
    margin: 2em 0 0.75em;
    padding-bottom: 0.35em;
    border-bottom: 2px solid var(--ep-violet-soft);
    font-size: 0.78em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ep-violet);
}

.ep-toc__chapter {
    margin: 1.1em 0 0;
}

.ep-toc__chapter > h4 {
    margin: 0 0 0.3em;
    font-size: 1.02em;
    font-weight: 600;
}

.ep-toc__num {
    display: inline-block;
    min-width: 2.1em;
    color: var(--ep-muted);
    font-variant-numeric: tabular-nums;
}

.ep-toc__sections {
    margin: 0.2em 0 0 2.1em;
    padding: 0;
    list-style: none;
    color: var(--ep-muted);
    font-size: 0.92em;
}

.ep-toc__sections li {
    list-style: none;
    padding: 0.08em 0;
}

.ep-tag {
    display: inline-block;
    font-size: 0.7em;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 3px;
    padding: 0.12em 0.5em;
    margin-left: 0.5em;
    vertical-align: 0.12em;
    background: var(--ep-violet-soft);
    color: var(--ep-violet);
    white-space: nowrap;
}

.ep-tag--free {
    background: #dcfce7;
    color: #166534;
}

/* --------------------------------------------------- exercise chapters --- */

.ep-chapters {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
}

.ep-chapters th,
.ep-chapters td {
    text-align: left;
    padding: 0.55em 0.7em;
    border-bottom: 1px solid var(--ep-rule);
    vertical-align: baseline;
}

.ep-chapters th {
    font-size: 0.78em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ep-muted);
}

.ep-chapters td:last-child,
.ep-chapters th:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ------------------------------------------------- solution disclosure --- */

details {
    border: 1px solid var(--ep-rule);
    border-left: 3px solid var(--ep-violet);
    border-radius: 5px;
    padding: 0.35em 1em;
    margin: 0.6em 0 1.6em;
    background: var(--ep-tint);
}

details[open] {
    padding-bottom: 0.6em;
}

/* The default disclosure triangle is suppressed and redrawn as a ::before,
 * because the native one is invisible here: the theme's reset zeroes the
 * summary's list-style, and Safari needs the -webkit pseudo-element removed
 * before a custom marker will sit in the right place. Without a visible marker
 * a folded solution reads as a static heading and never gets clicked. */
details > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ep-violet);
    padding: 0.5em 0;
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::before {
    content: "\25B8";           /* ▸ */
    display: inline-block;
    width: 1.1em;
    font-size: 0.95em;
}

details[open] > summary::before {
    content: "\25BE";           /* ▾ */
}

details > summary:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------- notes --- */

.ep-note {
    border-left: 3px solid var(--ep-violet);
    background: var(--ep-tint);
    border-radius: 0 5px 5px 0;
    padding: 0.85em 1.1em;
    margin: 1.5em 0;
}

.ep-note > :first-child { margin-top: 0; }
.ep-note > :last-child { margin-bottom: 0; }

/* Errata: an empty list is good news, so say so rather than showing nothing. */
.ep-empty {
    border: 1px dashed var(--ep-rule);
    border-radius: 6px;
    padding: 1.4em;
    text-align: center;
    color: var(--ep-muted);
    background: var(--ep-tint);
}

@media (max-width: 600px) {
    .ep-hero { gap: 1.4em; }
    .ep-hero__cover { flex-basis: 165px; max-width: 165px; margin: 0 auto; }
    .ep-toc__sections { margin-left: 1em; }
}
