@font-face {
    font-family: Cairo;
    src: url("cairo.woff2") format("woff2");
    font-display: swap;
    unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF;
}
:root {
    color-scheme: light;
    --accent: #443521;
    --ink: #26211b;
    --muted: #6c6255;
    --page: #f7f5ef;
    --paper: #fffefa;
    --line: #e8dfd0;
    --gold: #b88b43;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 1rem/1.8 Cairo, Tahoma, sans-serif; }
.wrap { width: calc(100% - 2rem); max-width: 66rem; margin: 0 auto; }
.masthead { text-align: center; color: var(--ink); padding-block: 1.05rem 1.2rem; background: radial-gradient(ellipse at 50% 70%, #fffefa 24%, #faf5e8 76%); border-block-start: 3px solid var(--gold); border-block-end: 1px solid var(--line); }

h1 { font-size: clamp(2.45rem, 7vw, 4rem); line-height: 1.2; margin: .3rem 0; letter-spacing: -.04em; }
.masthead h1 { display: grid; place-items: center; gap: 0; margin: 0; }
.masthead-caption { display: block; height: auto; }
.masthead-caption-top { width: 62%; max-width: 11rem; }
.masthead-caption-bottom { width: 38%; max-width: 6.65rem; }
.masthead-wordmark { display: block; position: relative; width: 100%; max-width: 22rem; }
.masthead-logo { display: block; width: 100%; height: auto; filter: invert(49%) sepia(86%) saturate(542%) hue-rotate(355deg); }

@supports ((mask-image: url("mohamed-gamal-calligraphy.png")) or (-webkit-mask-image: url("mohamed-gamal-calligraphy.png"))) {
    .masthead-wordmark { filter: drop-shadow(0 1px 1px #75501366); }
    .masthead-logo { opacity: 0; }
    .masthead-wordmark::after {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        -webkit-mask: url("mohamed-gamal-calligraphy.png") center / contain no-repeat;
        mask: url("mohamed-gamal-calligraphy.png") center / contain no-repeat;
        background:
            linear-gradient(112deg, transparent 43%, #ffedab 48%, #fffcdf 50%, #ffedab 52%, transparent 57%) 100% 0 / 290% 100% no-repeat,
            linear-gradient(177deg, #a16a13 5%, #d39729 30%, #f3c75b 43%, #ba7a18 57%, #754608 77%, #b77b21 93%);
        animation: wordmark-shine 5s ease-in-out infinite;
    }
}
@keyframes wordmark-shine {
    0%, 20% { background-position: 100% 0, 0 0; }
    68%, 100% { background-position: 0 0, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    .masthead-wordmark::after { animation: none; }
}
.ornament { width: 3rem; height: 2px; margin: .9rem auto 0; background: var(--gold); }
main { padding-block: 1.4rem 3.5rem; }
.controls { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .8rem 1.3rem; padding: .95rem 1.15rem; background: var(--paper); border: 1px solid var(--line); border-radius: .85rem; }
.search { flex: 1 1 16rem; display: grid; gap: .3rem; font-size: .9rem; font-weight: 700; }
.search input { width: 100%; min-height: 2.7rem; padding: .45rem .8rem; font: inherit; font-weight: 400; color: var(--ink); border: 1px solid var(--line); border-radius: .45rem; background: var(--page); }
.filters, .actions { display: flex; flex-wrap: wrap; gap: .45rem; }
button, .action { display: inline-flex; align-items: center; min-height: 2.6rem; padding: .25rem .8rem; border: 1px solid var(--line); border-radius: .45rem; background: var(--paper); font: inherit; color: var(--accent); text-decoration: none; cursor: pointer; }
button[aria-pressed="true"], .action:hover, button.action[aria-expanded="true"] { background: var(--accent); color: white; border-color: var(--accent); }
:focus-visible { outline: 3px solid #967441; outline-offset: 3px; }
.results { margin: 1.05rem 0 .5rem; color: var(--muted); font-size: .9rem; }
.item { background: var(--paper); border: 1px solid var(--line); border-radius: .8rem; padding: 1rem 1.2rem; margin-block-end: .65rem; box-shadow: 0 2px 5px #40280808; }
.item h2 { font-size: 1.06rem; margin: 0 0 .6rem; line-height: 1.7; overflow-wrap: anywhere; }
.player { margin-block-start: .75rem; }
.player :is(audio, video) { display: block; width: 100%; }
.player video { max-height: min(60vh, 34rem); background: #14231e; }
.player p { margin-bottom: 0; }
@media (max-width: 30rem) {
    .masthead { padding-block: .85rem 1rem; }
    .item { padding: .75rem; }
}

[hidden] { display: none !important; }
.reader-header { background: #fbf5e8; color: var(--ink); padding-block: 1.15rem; border-bottom: 1px solid var(--line); }
.reader-header a { color: var(--accent); }
.reader-header h1 { font-size: clamp(1.4rem, 4vw, 2.25rem); line-height: 1.5; margin-block-start: .5rem; letter-spacing: 0; }
.reader { padding-top: 1rem; }
.reader-controls { position: sticky; top: 0; display: flex; justify-content: center; align-items: center; gap: .75rem; padding: .6rem; background: var(--page); }
.reader-controls button:disabled { opacity: .5; cursor: default; }
#reader-status { text-align: center; }
#pdf-page { display: block; width: 100%; height: auto; background: white; border: 1px solid var(--line); }

.sound-item { padding-block: 1rem; }
.sound-item h2 { margin-block-end: .75rem; }
.sound-item .actions { margin-block-start: .7rem; }
.sound-track {
    --sound-accent: #765024;
    --sound-progress: #a67334;
    display: grid;
    grid-template-columns: 2.9rem minmax(0, 1fr);
    align-items: start;
    gap: .55rem .85rem;
}
.sound-play {
    width: 2.9rem;
    min-height: 2.9rem;
    padding: 0;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: var(--sound-accent);
    color: white;
}
.sound-play:hover { background: #62401d; }
.sound-play span {
    width: 0;
    height: 0;
    margin-left: .14rem;
    border-block: .47rem solid transparent;
    border-left: .73rem solid currentColor;
}
.sound-play.playing span {
    width: .7rem;
    height: .89rem;
    margin: 0;
    border: 0;
    border-inline: .23rem solid currentColor;
}
.sound-timeline { min-width: 0; }
.sound-seek { position: relative; border-radius: .35rem; }
.sound-seek:focus-within { outline: 2px solid var(--sound-accent); outline-offset: 3px; }
.sound-wave { height: 2.9rem; display: flex; align-items: center; gap: clamp(1px,.23vw,3px); }
.sound-wave span { flex: 1; height: var(--peak); min-width: 0; border-radius: 2px; background: #c6b9a2; }
.sound-wave span.played { background: var(--sound-progress); }
.sound-seek input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.sound-times { display: flex; justify-content: space-between; color: var(--muted); font: .82rem/1.45 Tahoma, sans-serif; font-variant-numeric: tabular-nums; }
.sound-notice { grid-column: 1 / -1; margin: 0; color: var(--sound-accent); }

.sound-wave.live span { transform: scaleY(var(--live-scale, 1)); transition: transform 55ms linear; }
.sound-volume { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; margin-top: .3rem; color: var(--muted); font-size: .875rem; }
.sound-volume input { width: 6rem; accent-color: var(--sound-accent); }
@media (prefers-reduced-motion: reduce) {
    .sound-wave.live span { transform: none; transition: none; }
}

.filters { padding: .2rem; border: 1px solid var(--line); border-radius: .55rem; gap: .15rem; }
.filters button { min-height: 2.2rem; border: 0; padding-inline: .62rem; font-size: .9rem; }
.filters button:not([aria-pressed="true"]):hover { background: var(--page); }
.item .action { min-height: 2.2rem; font-size: .9rem; }
.sound-volume { margin-top: .12rem; }
@media (max-width: 36rem) {
    .controls { padding: .8rem; }
    .filters { width: 100%; }
    .filters button { flex: 1 1 auto; justify-content: center; padding-inline: .4rem; }
}