@font-face {
    font-family: "Dashtseden";
    src: url("fonts/Dashtseden.woff2") format("woff2"),
         url("fonts/Dashtseden.ttf") format("truetype");
    unicode-range: U+1800-18AF, U+11660-1167F, U+202F;   /* only Mongolian characters use it */
    font-display: swap;
}

* {
    box-sizing: border-box;
    font-family: Garamond, Baskerville, "Baskerville Old Face", "Hoefler Text", "Times New Roman", serif;
}

html {
    height: 100%;
}

body {
    margin: 0 auto;
    padding: 20px;
    max-width: 1200px;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #EFE4CB;
}

a {
    text-decoration: none;
}

/* ---------- page frame ---------- */

.container {
    flex: 1;
    min-height: 0;
    width: 95%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.topnav {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    width: 100%;
    height: 60px;
}

.topnav a {
    color: #000;
    padding: 20px 30px;
    font-size: 24px;
}

.page-header {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 10px;
    margin-top: 20px;
    margin-bottom: 30px;
}

.page-header p {
    margin: 0;
}

.page-header a {
    justify-self: start;
}

.page-header small {
    justify-self: end;
}

/* ---------- the changing centre object ---------- */

.stage {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 50px;   /* keeps the art clear of the buttons */
    position: relative; 
}

.stage svg,
.stage img {
    height: 100%;
    width: auto;
    max-width: 100%;
}

.stage path {
    pointer-events: all;     /* see note 1 */
    cursor: pointer;
}

#inputField {
    position: absolute;
    display: none;
    width: 140px;
    font-family: Garamond, Baskerville, "Baskerville Old Face", "Hoefler Text",
                 "Times New Roman", "Dashtseden", "Noto Sans Mongolian", "Mongolian Baiti", serif;
}

.bone-word {
    font-size: 8px;
    text-anchor: middle;
    dominant-baseline: middle;
    fill: #000;
    stroke: none;
    cursor: pointer;
    font-family: Garamond, Baskerville, "Baskerville Old Face", "Hoefler Text",
                 "Times New Roman", "Dashtseden", "Noto Sans Mongolian", "Mongolian Baiti", serif; 
}

.circle {
    cursor: pointer;
}

.circle.selected {
    outline: 2px solid #000;
    outline-offset: 2px;
}

/* ---------- colour dots ---------- */

.colors {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

#color-one   { background-color: #FC6161; }
#color-two   { background-color: #FFE08D; }
#color-three { background-color: #8DE28D; }
#color-four  { background-color: #61AEFC; }
#color-five  { background-color: #9F61FC; }
#color-six   { background-color: #000; }
#color-seven {background-color: white;}

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

.hide-btn,
.download-btn {
    position: absolute;
    bottom: 0;
    letter-spacing: 0.7px;
    font-size: medium;
}

.letter-spacing span:first-child {
    position: relative;
    top: 3px;
}

.hide-btn     { left: 0;  background-color: #C6DBEF; }
.download-btn { right: 0; background-color: #DCCBFF; }

.hide-btn:hover     { background-color: #92afca; }
.download-btn:hover { background-color: #ad90e7; }

.hide-btn:active,
.download-btn:active { transform: scale(0.98); }

/* ---------- bones ---------- */
.skull-menu {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 70px 40px;            /* more space between rows and columns */
    max-width: 1100px;
    margin: 40px auto 0;
    justify-items: center;
}

.skull-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

/* Same height for every image, regardless of its file size or shape */
.skull-item img {
    height: 200px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    mix-blend-mode: multiply;
}

/* Bottom row slightly smaller */
.left-ear img,
.hyoid img,
.palatine img,
.right-ear img {
    height: 140px;
    mix-blend-mode: multiply;
}

.caption {
    margin-top: 14px;
    font-size: 0.95rem;
    text-align: center;
}

.skull-item:hover .caption {
    text-decoration: underline;
}

/* Layout: 3 on top, 4 on the bottom */
.left-skull  { grid-row: 1; grid-column: 1 / span 4; }
.front-skull { grid-row: 1; grid-column: 5 / span 4; }
.right-skull { grid-row: 1; grid-column: 9 / span 4; }

.left-ear    { grid-row: 2; grid-column: 1 / span 3; }
.hyoid       { grid-row: 2; grid-column: 4 / span 3; }
.palatine    { grid-row: 2; grid-column: 7 / span 3; }
.right-ear   { grid-row: 2; grid-column: 10 / span 3; }

.text-settings {
    width: 200px;       /* overall box width */
    height: 48px;      /* overall box height */

    border: 2px solid black;
    background: white;

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

    font-family: "Times New Roman", Times, serif;
    font-size: 20px;    /* size of 15, B, I, A, T */

    position: absolute;
    display: none;
}

.text-settings button {
    width: 36px;
    height: 36px;
}

.underline::after {
    width: 24px;
    height: 3px;
    bottom: 4px;
}

.letter-spacing .arrows {
    font-size: 16px;
}


/* Italic 15 */
.font-size {
    font-style: italic;
}


/* Bold B */
.bold {
    font-weight: bold;
}


/* Italic I */
.italic {
    font-style: italic;
}


/* Underlined A */
.underline {
    position: relative;
}

.underline::after {
    content: "";
    position: absolute;

    width: 22px;
    height: 4px;

    background: #ff5c5c;
    border-radius: 10px;

    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
}


/* T with horizontal arrows */
.letter-spacing {
    display: flex;
    flex-direction: column;
    line-height: 0.8;
}

.letter-spacing .arrows {
    font-size: 28px;
}

.wheel {
    position: relative;
    background: conic-gradient(#ff3b30, #ff9500, #ffd60a, #34c759, #00b8d4, #0a66ff, #a635e8, #ff2d92, #ff3b30);
}

.wheel input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;          /* invisible, but still clickable on top of the gradient */
    cursor: pointer;
}

.stage.painting path {
    cursor: crosshair;
}

.text-settings {
    width: 240px;            /* room for the sixth button */
}

.stage.painting .bone-word {
    pointer-events: none;    /* in color mode, clicks go through words to the bone */
}

.stage svg {
    user-select: none;
    -webkit-user-select: none;
}

.hide-btn.active {
    background-color: #92afca;
    outline: 2px solid #000;
}

.stage.hiding path {
    cursor: crosshair;
}

#downloadDialog {
    border: 2px solid #000;
    background: #EFE4CB;
    padding: 24px 32px;
    text-align: center;
}

#downloadDialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

#downloadDialog button {
    margin: 0 6px;
    font-size: medium;
}

.hide-btn,
.undo-btn,
.download-btn {
    position: absolute;
    bottom: 0;
    letter-spacing: 0.7px;
    font-size: medium;
}

.undo-btn { left: 56px; background-color: #C6DBEF; }
.undo-btn:hover { background-color: #92afca; }
.undo-btn:active { transform: scale(0.98); }


.bone-word {
    cursor: grab;
    touch-action: none;
}

/* ---------- settings menu: extra rows ---------- */
.text-settings {
    flex-wrap: wrap;
    height: auto;
    row-gap: 6px;
    padding: 6px 0;
}

.settings-row {
    flex-basis: 100%;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.settings-row[hidden] {
    display: none;
}

.word-swatch {
    width: 22px !important;
    height: 22px !important;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.underline.active {
    outline: 2px solid #000;
}

/* ---------- rotation handle ---------- */
.rotate-handle {
    fill: #fff;
    stroke: #000;
    cursor: grab;
    touch-action: none;
}

.rotate-line {
    stroke: #000;
    stroke-dasharray: 2 2;
    pointer-events: none;
}

/* ---------- index: controls, presentation, footer ---------- */
.index-controls {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.index-controls button {
    font-size: medium;
    letter-spacing: 0.7px;
    background-color: #C6DBEF;
}

.index-controls button:hover { background-color: #92afca; }

.index-controls button.active {
    background-color: #92afca;
    outline: 2px solid #000;
}

.stage svg.no-outline path {
    stroke: none !important;
    fill: none !important;
}

.stage svg.no-words #index-words {
    display: none;
}

/* ---------- word color: "any color" wheel in the settings menu ---------- */
.word-wheel {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: conic-gradient(#ff3b30, #ff9500, #ffd60a, #34c759, #00b8d4, #0a66ff, #a635e8, #ff2d92, #ff3b30);
    cursor: pointer;
}

.word-wheel input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ---------- index: toggles next to Present ---------- */
.index-toggles {
    position: absolute;
    bottom: 0;
    left: 100px;
    display: flex;
    gap: 6px;
}

.index-toggles button {
    font-size: medium;
    letter-spacing: 0.7px;
    background-color: #C6DBEF;
}

.index-toggles button:hover { background-color: #92afca; }

.index-toggles button.active,
.mode-btn.active {
    background-color: #92afca;
    outline: 2px solid #000;
}

.stage svg.no-outline path {
    stroke: none !important;
    fill: none !important;
}

.stage svg.no-words #index-words {
    display: none;
}

/* ---------- footer: same line as the bottom buttons, on every page ---------- */
.site-footer {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 2px 0;
    font-size: 18px;
    font-style: italic;
    letter-spacing: 0.7px;
    white-space: nowrap;
    pointer-events: none;
}

/* ---------- index: editable title ---------- */
.page-header p[contenteditable] {
    min-width: 120px;
    text-align: center;
    outline: none;
    cursor: text;
}

.page-header p[contenteditable]:empty::before {
    content: 'Title';
    opacity: 0.4;
}

/* ---------- contact page ---------- */
.contact {
    flex: 1;                          /* fill the space between the navigation and the footer */
    min-height: 0;                    /* lets it scroll instead of growing past the window */
    overflow-y: auto;                 /* the page body doesn't scroll, so this area does */
    margin: 30px auto 50px;           /* top: room below the navigation, bottom: room for the footer */
    width: 100%;
    max-width: 900px;
    padding-right: 12px;              /* keeps text clear of the scrollbar */
}

.contact-form {
    max-width: 480px;
    margin-top: 28px;
    padding-bottom: 20px;
}

.contact-form label {
    display: block;
    margin-bottom: 16px;
}

.contact-form .optional {
    font-size: 0.85em;
    opacity: 0.6;
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form select,
.contact-form textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    font: inherit;
    padding: 6px 8px;
    border: 1px solid #000;
    background: #fff;
}

.contact-form input[type="file"] {
    display: block;
    margin-top: 6px;
    font: inherit;
}

.contact-form textarea {
    resize: vertical;
}

.contact-form button {
    font-size: medium;
    letter-spacing: 0.7px;
    background-color: #DCCBFF;
    padding: 4px 18px;
}

.contact-form button:hover { background-color: #ad90e7; }
.contact-form button:disabled { opacity: 0.6; cursor: default; }

.form-status {
    max-width: 480px;
    min-height: 1.5em;
}

.form-status.success { color: #2e6b2e; }
.form-status.error { color: #b00020; }

#safetyNotice {
    border: 1px solid #000;
    background: #ece3cc;
    padding: 24px 28px;
    max-width: 360px;
    text-align: center;
    font-family: inherit;
}
#safetyNotice::backdrop {
    background: rgba(0, 0, 0, 0.25);
}
#safetyNotice p {
    margin: 0 0 10px;
}
#safetyNotice button {
    margin-top: 8px;
    font-family: inherit;
    font-size: 1rem;
    padding: 2px 14px;
    cursor: pointer;
}

.center {
    text-align: center;
}

#wordList {
    border: 1px solid #000;
    background: #ece3cc;
    padding: 24px 28px;
    width: min(420px, 90vw);
    max-height: 70vh;
    overflow-y: auto;
    font-family: inherit;
}
#wordList::backdrop {
    background: rgba(0, 0, 0, 0.25);
}
#wordList .list-title {
    text-align: center;
    margin: 0 0 16px;
}
#wordList h3 {
    font-size: 1rem;
    font-weight: normal;
    margin: 16px 0 6px;
    border-bottom: 1px solid #0003;
}
#wordList ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
#wordList li {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}
#wordList .bone {
    text-transform: capitalize;
    opacity: 0.7;
}
#wordList .word {
    font-style: italic;
}
#wordList .close {
    display: block;
    margin: 18px auto 0;
    font-family: inherit;
    padding: 2px 14px;
}

.count-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* ---------- info button (next to Undo) ---------- */
.info-btn {
    position: absolute;
    bottom: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #000;
    border-radius: 50%;
    background: transparent;
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
}

.info-btn.active {
    background: #000;
    color: #EFE4CB;
}

/* hover message, opens upward */
.info-btn::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 130%;
    left: 0;
    width: max-content;
    max-width: 220px;
    padding: 6px 10px;
    background: #EFE4CB;
    border: 1px solid #000;
    font-style: normal;
    font-size: 0.8rem;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 1000;
}

.info-btn:hover::after,
.info-btn:focus-visible::after {
    opacity: 1;
}

/* bone name tooltip */
.bone-tip {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    background: #EFE4CB;
    border: 1px solid #000;
    padding: 3px 8px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.info-mode .stage svg path {
    cursor: help;
}

/* ---------- phones (700px and narrower only) ---------- */
@media (max-width: 700px) {
    /* let the page scroll */
    body { padding: 12px; height: auto; min-height: 100dvh; overflow-y: auto; }
    .container { width: 100%; }

    /* nav on one line */
    .topnav { height: auto; }
    .topnav a { padding: 12px 14px; font-size: 20px; }
    .page-header { margin-top: 10px; margin-bottom: 16px; }

    /* drawing takes most of the screen; colours go in a row underneath */
    .stage { flex: none; height: 65dvh; padding-bottom: 0; }
    .colors { position: static; transform: none; flex-direction: row; flex-wrap: wrap;
              justify-content: center; gap: 12px; margin: 16px 0 100px; }

    /* buttons stay on the bottom line; the footer moves up one line above them */
    .site-footer { bottom: 34px; font-size: 15px; }
    .index-toggles { left: 0; bottom: 64px; }      /* index "Present" mode only */

    /* skull menu: 2 per row */
    .skull-menu { grid-template-columns: repeat(2, 1fr); gap: 32px 16px;
                  margin-top: 20px; padding-bottom: 70px; }
    .skull-menu .skull-item { grid-row: auto; grid-column: auto; }
    .skull-menu .skull-item img { height: 140px; }
    .skull-menu .left-ear img, .skull-menu .hyoid img,
    .skull-menu .palatine img, .skull-menu .right-ear img { height: 110px; }
}