/*****************************************************************************
*
* External
*
*****************************************************************************/

@import url("https://use.typekit.net/gqp2vyu.css");
@import url("/birdview/css/birdview.css");

/*****************************************************************************
*
* Variables
*
*****************************************************************************/

:root{
    --page-background: #fff;
    --text-color: #111;
    --secondary-text-color: rgba(0, 0, 0, 0.6);

    --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    --monospace: "Menlo", Consolas, monospace;

    --article-width: 672px;
    --caption-width: 512px;
    --gallery-width: 1248px;
    --gallery-side-padding: 16px;
    --gallery-gap: 16px;

    --separator-margin: 2rem;
    --article-bottom-padding: 2rem;
    --wide-content-width: calc(var(--gallery-width) + var(--gallery-side-padding) + var(--gallery-side-padding));

    --brand-padding-top: 1.5em;
    --brand-padding-bottom: 1em;
    --h1-family: "Futura-PT";
    --h1-color: var(--text-color);
    --h1-size: 2.5rem;
    --h1-responsive-scale: 0.75;
    --h1-weight: 700;
    --h1-line-height: 1.25;
    --h1-letter-spacing: -1px;
    --h1-transform: scaleX(0.95) scaleY(1.05);

    --h2-family: "Futura-PT";
    --h2-size: 1.625rem;
    --h2-weight: 700;
    --h2-line-height: 1.5;
    --h2-letter-spacing: 0px;
    --h2-transform: scaleX(0.95) scaleY(1.05);

    --h3-family: var(--body);
    --h3-size: 1.0625rem;
    --h3-weight: 700;
    --h3-line-height: 1.5;
    --h3-letter-spacing: 0px;
    --h3-transform: scaleX(1) scaleY(1);

    --content-family: var(--body);
    --content-size: 1rem;
    --content-weight: 400;
    --content-line-height: 1.7;

    --info-family: "Futura-PT";
    --info-size: 1em;
    --info-weight: 400;
    --info-line-height: 1.5;

    --gist-width: 100%;
    --gist-family: var(--body);
    --gist-size: 1rem;
    --gist-weight: 300;
    --gist-style: italic;
    --gist-line-height: 1.6;

    --footer-family: var(--body);
    --footer-size: 1rem;
    --footer-weight: 300;
    --footer-line-height: 1.5;
}

/*****************************************************************************
*
* Base
*
*****************************************************************************/

html{
    font-size: 16px;
}

body,
.editor_page{
    background-color: var(--page-background-color, var(--page-background));
}

/*× The whole content is wrapped inside main. */
main,
.editor_page{
    container: document / inline-size;
    background-position: top center;
    background-repeat: no-repeat;
}

body{
    margin: 0;
    padding: 0;
    color: var(--text-color);
    font-family: var(--body);
    overflow-y: scroll;
}

a, button, label, input{
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

*{
    box-sizing: border-box;
}

a,
u{
    text-decoration-thickness: 1px;
    text-underline-offset: 0.125em;
}

/*× Avoid double underlines when a link is styled as underlined in the editor. */
a u{
    /* text-decoration: none; */
}

.article h1 :is(a, u){
    text-decoration-thickness: 2px;
    text-underline-offset: 0.125em;
}

/*****************************************************************************
*
* Header
*
*****************************************************************************/

.blog_header{
    /*× same width as regular content. */
    width: min(var(--article-width), calc(100% - var(--gallery-side-padding) - var(--gallery-side-padding)));
    margin: 0 auto;
    border: 0;
}

.brand_image{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0 auto;
    padding: var(--brand-padding-top) 1em var(--brand-padding-bottom);
}

.brand_image > a{
    display: block;
    min-width: 0;
    max-width: 100%;
}

.brand_image[data-no-space-above]{
    padding-top: 0;
}

.brand_image[data-no-space-below]{
    padding-bottom: 0;
}

/*× Default Achraf logo. */
.brand_image:not(:has([data-brand-image])){
    max-width: 100px;
    padding-inline: 0;
}

.brand_image img{
    display: block;
    width: 32px;
    height: auto;
}

.brand_image img[data-brand-image]{
    max-width: 100%;
    height: auto;
}

/*****************************************************************************
*
* Article Layout
*
*****************************************************************************/

/*

Regular content occupies the middle column.
Wide figure content may use the flexible outer columns.
`.article_content` is the editable part in the editor.

*/
.article,
.article_content{
    display: grid;
    grid-template-columns: minmax(var(--gallery-side-padding), 1fr) minmax(0, min(var(--article-width), calc(100% - var(--gallery-side-padding) - var(--gallery-side-padding)))) minmax(var(--gallery-side-padding), 1fr);
}

.article{
    max-width: var(--wide-content-width);
    margin: 0 auto;
    padding: 0 0 var(--article-bottom-padding);
    color: var(--text-color);
    font-family: var(--content-family);
    font-size: var(--content-size);
    font-weight: var(--content-weight);
    line-height: var(--content-line-height);
}

.article > *,
.article_content > *{
    grid-column: 2;
    min-width: 0;
}

.article > .wide,
.article > .grid,
.article_content > .wide,
.article_content > .grid{
    grid-column: 1 / -1;
    justify-self: center;
    width: min(var(--gallery-width), calc(100% - var(--gallery-side-padding) - var(--gallery-side-padding)));
}

/*****************************************************************************
*
* Article Header
*
*****************************************************************************/

.article_header{
    margin: 0;
    padding: 0;
}

.article_title_row{
    margin: 0;
    padding: 0;
}

.article h1{
    color: var(--text-ink, var(--h1-color));
    margin: 0;
    padding: 0;
    font-family: var(--h1-family);
    --block-default-size: var(--h1-size);
    --block-default-weight: var(--h1-weight);
    --block-default-leading: var(--h1-line-height);
    text-align: center;
    letter-spacing: var(--h1-letter-spacing);
    transform: var(--h1-transform);
}

.article h1 a{
    color: inherit;
    text-decoration-line: none;
}

.article h1 a:hover,
.article h1 a:active{
    text-decoration-line: underline;
}

.article .info{
    margin: 0;
    padding: 0.25rem 0 0;
    color: var(--secondary-text-color);
    font-family: var(--info-family);
    font-size: var(--info-size);
    font-weight: var(--info-weight);
    line-height: var(--info-line-height);
    text-align: center;
}

.article .info a{
    text-decoration-line: underline;
}

.article_header .info_date{
    opacity: 1;
}

.article_header .info_update_date{
    opacity: 1;
}

.article .gist{
    max-width: var(--gist-width);
    margin: 0 auto;
    padding: 2em 1em 1em;
    font-family: var(--gist-family);
    --block-default-size: var(--gist-size);
    --block-default-weight: var(--gist-weight);
    font-style: var(--gist-style);
    --block-default-leading: var(--gist-line-height);
}

/*****************************************************************************
*
* GitHub
*
*****************************************************************************/

.github_block{
    margin: 0;
    text-align: right;
}

/*× The gist keeps its usual spacing when there is no GitHub link. With a link,
* the two items share a row and wrap when the text would become too narrow.
* Change the gap here; order: -1 on .github_block puts the card first.
*/
.gist_row{
    --gist-gap: 1em;
    display: contents;
}

.gist_row:has(.github_block a){
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--gist-gap);
    margin: 0;
    padding: 2em 0 1em;
}

.gist_row:has(.github_block a) .gist{
    flex: 1 1 20rem;
    min-width: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.gist_row .github_block{
    flex: none;
    margin: 0;
}

.gist_row .github_block:empty{
    display: none;
}

.github_block a{
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 2rem;
    border: 0;
    border-radius: 3px;
    background: #2b3137;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.github_block a strong{
    font-family: var(--body);
    font-size: 1rem;
    font-weight: bold;
    line-height: 1.5;
}

.github_block a span{
    font-family: var(--monospace);
    font-size: 0.7rem;
    line-height: 1.5;
}

.github_block a:hover{
    background: #424a53;
}

/*****************************************************************************
*
* Typography
*
*****************************************************************************/

/*× Every text block uses one size and line-height calculation. Responsive rules change the role's scale. */
.article :is(h1, h2, h3, p, li, figcaption, pre):where(:not(.info)){
    --block-scale: 1;
    font-size: calc(var(--text-size, var(--block-default-size, 1rem)) * var(--block-scale));
    font-weight: var(--text-weight, var(--block-default-weight, inherit));
    line-height: var(--text-leading, var(--block-default-leading, var(--content-line-height)));
    overflow-wrap: anywhere;
}

.article :is(h1, h2, h3, p, figcaption, pre)[data-text-color]{
    color: var(--text-ink);
}

.article pre[data-text-color] code,
.article pre[data-text-color] code span{
    color: var(--text-ink) !important;
}

.article h2{
    margin: 1em 0 0;
    font-family: var(--h2-family);
    --block-default-size: var(--h2-size);
    --block-default-weight: var(--h2-weight);
    --block-default-leading: var(--h2-line-height);
    letter-spacing: var(--h2-letter-spacing);
    transform: var(--h2-transform);
    transform-origin: 0% 50%;
}

.article h2 + p{
    margin-top: 0.75em;
}

.article h3{
    margin: 1em 0 0;
    font-family: var(--h3-family);
    --block-default-size: var(--h3-size);
    --block-default-weight: var(--h3-weight);
    --block-default-leading: var(--h3-line-height);
    letter-spacing: var(--h3-letter-spacing);
    transform: var(--h3-transform);
    transform-origin: 0% 50%;
}

.article h3 + p{
    margin-top: 0.5em;
}

/*× Heading text is an inline self-link; only the text is clickable. */
.article :is(h2, h3)[id]{
    scroll-margin-block-start: 1em;
}

.article .heading_permalink{
    display: inline;
    color: inherit;
    text-decoration: none;
}

.article .heading_permalink:is(:hover, :active, :focus-visible){
    text-decoration-line: underline;
}

/*× Touch-specific heading-link styles can be defined here. */
@media (hover: none){
}

.article p:where(:not(.info):not(.gist)){
    margin-top: 1em;
    margin-bottom: 0;
}

.article ul,
.article ol{
    margin-top: 0.5em;
    margin-bottom: 0;
    padding-left: 1.5rem;
}

.article li{
    --block-default-size: 1em;
    margin: 0.35em 0;
    padding-left: 0.25em;
}

.article li > p{
    --block-default-size: 1em;
}

.article li > p:first-child{
    margin: 0;
}

.article li > ul,
.article li > ol{
    margin: 0.5em 0 0;
}

.article blockquote{
    margin: 1em 0;
    padding-left: 1em;
    border-left: 1px solid rgba(0, 0, 0, 0.4);
}

.article blockquote p{
    margin: 0.5em 0;
    font-style: italic;
    --block-default-leading: 1.8;
}

.article blockquote cite{
    display: block;
    margin-top: 0.5rem;
    font-style: normal;
}

.article q{
    font-style: italic;
}

.article aside{
    position: relative;
    margin: 1.5rem 0;
    padding: 0 1rem 1rem 4rem;
    font-style: italic;
    background-color: rgba(128, 128, 128, 0.05);
    border: 1px solid rgba(128, 128, 128, 0.2);
}

.article aside::before{
    position: absolute;
    top: 50%;
    left: 1rem;
    display: block;
    width: 2rem;
    height: 2rem;
    margin-top: -1rem;
    color: rgba(0, 0, 0, 0.4);
    font-style: italic;
    font-weight: 700;
    line-height: 2rem;
    text-align: center;
    content: "i";
    border: 1px solid rgba(0, 0, 0, 0.4);
    border-radius: 50%;
}

.article .left_align{
    text-align: left;
}

.article .center{
    text-align: center;
}

.article .right_align{
    text-align: right;
}

/*****************************************************************************
*
* Code
*
*****************************************************************************/

.article code{
    margin: 0;
    padding: 0.1rem 0.25rem;
    font-family: var(--monospace);
    font-size: 0.9em;
    background-color: rgba(240, 240, 240, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.2rem;
}

.article pre{
    --block-default-size: 0.8rem;
    --block-default-leading: 1.5;
    margin: 1rem 0;
}

.article pre.wide{
    max-width: 900px;
}

.article pre code{
    display: block;
    padding: 0.85rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: pre;
    overflow-wrap: normal;
    overscroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

.article pre[data-language]{
    position: relative;
}

.article pre[data-language] code{
    color: var(--syntax-foreground);
}

.article pre[data-language]::after{
    content: attr(data-language);
    position: absolute;
    top: 4px;
    right: 6px;
    font: 0.65rem/1.2 system-ui, sans-serif;
    opacity: 0.65;
    pointer-events: none;
    user-select: none;
}

/*****************************************************************************
*
* Media Blocks
*
*****************************************************************************/

/*×
* Regular and wide figures stack vertically. Only grid figures form rows.
* Media keep their requested width, capped by their containing figure.
* Grid rows wrap naturally; JavaScript does not measure or rearrange them.
* Captions retain their independent editorial width in every layout.
*/
.article .media_block{
    display: flex;
    flex-direction: column;
    align-items: var(--figure-alignment, center);
    gap: var(--gallery-gap);
    margin: 1em 0;
}

.article .media_block.grid{
    flex-flow: row wrap;
    align-items: flex-start;
    /*
    This aligns the media row within the figure's available width.
    Use my own article From inline-block to CSS Grid to make a better CSS layout.
    */
    justify-content: var(--figure-alignment, center);
}

/*× Alignment moves media within the Regular, Wide or Grid area without resizing it. */
.media_block[data-align="left"]{
    --figure-alignment: flex-start;
}

.media_block[data-align="right"]{
    --figure-alignment: flex-end;
}

/*× Captions follow the chosen edge and retain their own maximum text width. */
.article .media_block[data-align="left"] figcaption{
    padding-inline: 0 max(0px, calc(100% - var(--caption-width)));
}

.article .media_block[data-align="right"] figcaption{
    padding-inline: max(0px, calc(100% - var(--caption-width))) 0;
}

.article .media_block.grid figcaption{
    flex-basis: 100%;
}

.article h2 + .media_block,
.article h3 + .media_block{
    margin-top: 0.75rem;
}

/*× Figure spacing choices remove the adjacent block's contribution to the same gap. */
.article .media_block[data-no-space-above]{
    margin-block-start: 0;
}

.article .media_block[data-no-space-below]{
    margin-block-end: 0;
}

:is(.article, .article_content) > :has(+ .media_block[data-no-space-above]){
    margin-block-end: 0;
}

:is(.article, .article_content) > .media_block[data-no-space-below] + *{
    margin-block-start: 0;
}

/*
* Every media item uses its specified width, capped by the available space.
*/
.article .media_block img,
.article .media_block video,
.article .media_block audio{
    display: block;
    flex: none;
    width: min(var(--media-width, 100%), 100%);
    height: auto;
    margin: 0;
}

.article .media_block audio{
    min-height: 3.375rem;
}

.article .media_block video:focus{
    outline: none;
}

.article figcaption{
    flex: none;
    width: 100%;
    padding-inline: max(var(--gallery-side-padding), calc((100% - var(--caption-width)) / 2));
    margin: 0;
    --block-default-size: 0.875rem;
    --block-default-leading: 1.5;
}

/*× Flex spacing also separates the caption row. Subtract that gap when the caption should touch its media. */
.article .media_block[data-no-caption-gap] figcaption{
    margin-block-start: calc(-1 * var(--gallery-gap));
}

/*×
* Referenced media share one presentation in the editor and generated articles.
* Published HTML supplies source dimensions before media loads.
* The editor also reads dimensions from the native load event.
* Explicit widths override defaults; only CSS constrains them to the figure.
*/
.article .media_item{
    flex: none;
    min-width: 0;
    max-width: 100%;
    width: min(var(--media-width, var(--media-default-width, var(--article-width))), 100%);
    margin: 0;
}

.article .media_item[data-media-type="image"],
.article .media_item[data-media-type="video"]{
    --media-default-width: calc(var(--media-source-width, calc(var(--article-width) * 2)) / 2);
}

.article .media_item[data-media-type="embed"]{
    --media-default-width: var(--embed-width, var(--article-width));
}

/*× An image link uses the image's full box as its click target. */
.article .media_item > a{
    display: block;
    width: 100%;
    margin: 0;
}

.article .media_item > img,
.article .media_item > a > img,
.article .media_item > video,
.article .media_item > audio,
.article .media_item > iframe{
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0;
}

.article .media_item > iframe{
    aspect-ratio: var(--embed-ratio, 16 / 9);
    border: 0;
}

.article .media_item > img,
.article .media_item > a > img,
.article .media_item > video{
    aspect-ratio: var(--media-source-ratio, auto);
}

.article .media_unavailable{
    display: block;
    padding: 1rem;
    border: 1px dashed currentColor;
    font-size: 0.875em;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.article .media_item > [hidden],
.article .media_item > a > img[hidden]{
    display: none;
}

/*****************************************************************************
*
* Media Player click-to-play
*
*****************************************************************************/

.media_item .embed_poster{
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: var(--embed-ratio, 16 / 9);
    padding: 0;
    border: 0;
    background: transparent;
    color: white;
    cursor: pointer;
}

.media_item .embed_poster img{
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.embed_play{
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    padding: 0.6rem 1rem;
    border-radius: 0.4rem;
    background: #e10000;
    font-size: 16px;
    font-weight: 500;
}

.media_item .embed_poster[hidden],
.media_item .embed_poster img[hidden],
.media_item iframe[hidden]{
    display: none;
}

/*****************************************************************************
*
* Separator
*
*****************************************************************************/

.article hr{
    width: 100%;
    margin: var(--separator-margin) 0;
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/*× Grid items keep independent margins; the separator owns both adjacent gaps. */
:is(.article, .article_content) > :has(+ hr){
    margin-block-end: 0;
}

:is(.article, .article_content) > hr + *{
    margin-block-start: 0;
}

/*× The article padding owns the gap above the footer, including the blog index. */
.article > :last-child,
.article_content > :last-child{
    margin-block-end: 0;
}

/*× Trailing nested content contributes no additional space after its final item. */
:is(.article, .article_content) > :last-child :last-child{
    margin-block-end: 0;
}

/*****************************************************************************
*
* Footer
*
*****************************************************************************/

.blog_footer{
    font-family: var(--footer-family);
    font-size: var(--footer-size);
    font-weight: var(--footer-weight);
    line-height: var(--footer-line-height);
    width: min(var(--article-width), calc(100% - 2rem));
    margin: 0 auto;
    padding: 2em 0 1em;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.1)
}

.keyboard_shortcuts{
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    max-width: max-content;
    margin: auto;
    padding: 1em;
    font-family: var(--body);
    border: 1px solid rgba(0, 0, 0, 0.07);
    background: rgba(0, 0, 0, 0.025);
}

.keyboard_shortcut{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--secondary-text-color);
    font-size: 0.625em;
}

.keyboard_shortcut img{
    width: 24px;
    height: 24px;
    object-fit: contain;
    opacity: 0.5;
}

.keycap{
    font-family: inherit;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    color: var(--secondary-text-color);
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.keycap:hover{
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 1);
}

.keycap:active{
    background-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}

.blog_copyright{
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.3em;
    margin: 1rem 0 0;
    color: var(--secondary-text-color);
    font-family: "Futura-PT";
    font-weight: 400;
    font-size: 16px;
    line-height: inherit;
}

.blog_copyright a{
    /* color: var(--secondary-text-color); */
}

/*****************************************************************************
*
* Responsive
*
*****************************************************************************/

/*× The available page width controls typography in both the editor pane and published pages. */
@container document (max-width: 47rem){

    .article h1{
        --block-scale: var(--h1-responsive-scale);
    }

}
