/* ---------------------------------------------------------------------------
   Forsíða — the die and the ring of links.
   --------------------------------------------------------------------------- */

:root {
    --ink:      #22262E;
    --brand:    #2F4858;
    --brand-dk: #22343F;
    --accent:   #C8843C;
    --accent-lt:#F0DFC6;
    --muted:    #6E7480;
    --bg:       #F7F6F3;
    --card:     #FFFFFF;
    --line:     #E3E0DA;
    --radius:   10px;
    --shadow:   0 6px 18px rgba(34, 38, 46, .07);

    --die-size: 104px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* --- Header ------------------------------------------------------------------ */

.site-header {
    background: var(--brand);
    color: #fff;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 19px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* A tiny five-pip die as the mark, drawn the same way as the big one. */
.brand-die {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: #fff;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 3px;
}

.brand-die span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--brand);
    align-self: center;
    justify-self: center;
}

.brand-die span:nth-child(1) { grid-area: 1 / 1; }
.brand-die span:nth-child(2) { grid-area: 1 / 3; }
.brand-die span:nth-child(3) { grid-area: 2 / 2; }
.brand-die span:nth-child(4) { grid-area: 3 / 1; }
.brand-die span:nth-child(5) { grid-area: 3 / 3; }

.site-nav { display: flex; gap: 18px; }

.site-nav a {
    color: var(--accent-lt);
    text-decoration: none;
    font-size: 15px;
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: #fff; }
.site-nav a.is-active { color: #fff; border-bottom-color: var(--accent); }

/* --- The stage ---------------------------------------------------------------- */

.stage { padding: 34px 0 10px; text-align: center; }

.tagline {
    color: var(--muted);
    font-size: 17px;
    margin: 0 0 10px;
}

/* The ring is a box; the links are placed on an ellipse inside it by the
   percentages the page works out. */
.ring {
    position: relative;
    width: 100%;
    max-width: 760px;
    height: 460px;
    margin: 0 auto;
}

.die-slot {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    perspective: 800px;
}

/* --- The die ------------------------------------------------------------------ */

.die {
    position: relative;
    width: var(--die-size);
    height: var(--die-size);
    transform-style: preserve-3d;
    transition: transform .9s cubic-bezier(.22, .68, .32, 1.01);
    transform: rotateX(-20deg) rotateY(-24deg);
}

/* Which way to turn the cube so a given number faces the viewer. Opposite
   faces sum to seven, so these six angles cover all of them. */
.die[data-face="1"] { transform: rotateX(-20deg) rotateY(-24deg); }
.die[data-face="2"] { transform: rotateX(-20deg) rotateY(-114deg); }
.die[data-face="3"] { transform: rotateX(-110deg) rotateY(0deg); }
.die[data-face="4"] { transform: rotateX(70deg) rotateY(0deg); }
.die[data-face="5"] { transform: rotateX(-20deg) rotateY(66deg); }
.die[data-face="6"] { transform: rotateX(-20deg) rotateY(156deg); }

.die.is-rolling {
    animation: tumble .9s cubic-bezier(.3, .1, .3, 1);
}

@keyframes tumble {
    0%   { transform: rotateX(-20deg) rotateY(-24deg); }
    100% { transform: rotateX(700deg) rotateY(880deg); }
}

.face {
    position: absolute;
    inset: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: inset 0 0 14px rgba(34, 38, 46, .06);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 12px;
}

.face i {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand);
    align-self: center;
    justify-self: center;
}

/* Pip layouts, face by face. */
.pips-1 i:nth-child(1) { grid-area: 2 / 2; }

.pips-2 i:nth-child(1) { grid-area: 1 / 1; }
.pips-2 i:nth-child(2) { grid-area: 3 / 3; }

.pips-3 i:nth-child(1) { grid-area: 1 / 1; }
.pips-3 i:nth-child(2) { grid-area: 2 / 2; }
.pips-3 i:nth-child(3) { grid-area: 3 / 3; }

.pips-4 i:nth-child(1) { grid-area: 1 / 1; }
.pips-4 i:nth-child(2) { grid-area: 1 / 3; }
.pips-4 i:nth-child(3) { grid-area: 3 / 1; }
.pips-4 i:nth-child(4) { grid-area: 3 / 3; }

.pips-5 i:nth-child(1) { grid-area: 1 / 1; }
.pips-5 i:nth-child(2) { grid-area: 1 / 3; }
.pips-5 i:nth-child(3) { grid-area: 2 / 2; }
.pips-5 i:nth-child(4) { grid-area: 3 / 1; }
.pips-5 i:nth-child(5) { grid-area: 3 / 3; }

.pips-6 i:nth-child(1) { grid-area: 1 / 1; }
.pips-6 i:nth-child(2) { grid-area: 1 / 3; }
.pips-6 i:nth-child(3) { grid-area: 2 / 1; }
.pips-6 i:nth-child(4) { grid-area: 2 / 3; }
.pips-6 i:nth-child(5) { grid-area: 3 / 1; }
.pips-6 i:nth-child(6) { grid-area: 3 / 3; }

/* Half the cube's width, pushed out along each axis. */
.face-front  { transform: translateZ(calc(var(--die-size) / 2)); }
.face-back   { transform: rotateY(180deg) translateZ(calc(var(--die-size) / 2)); }
.face-right  { transform: rotateY(90deg)  translateZ(calc(var(--die-size) / 2)); }
.face-left   { transform: rotateY(-90deg) translateZ(calc(var(--die-size) / 2)); }
.face-top    { transform: rotateX(90deg)  translateZ(calc(var(--die-size) / 2)); }
.face-bottom { transform: rotateX(-90deg) translateZ(calc(var(--die-size) / 2)); }

/* --- The links on the ring ------------------------------------------------------ */

.ring-link {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 180px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--ink);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.ring-link:hover {
    border-color: var(--accent);
    transform: translate(-50%, -50%) scale(1.04);
}

.ring-face {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    margin-bottom: 4px;
    border-radius: 999px;
    background: #F2F1ED;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.ring-label { display: block; font-weight: 700; font-size: 16px; }
.ring-note  { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

/* The link the die landed on. Keeps its own pastel — the accent ring and the
   badge are what mark it, so the card does not change colour underfoot. */
.ring-link.is-picked,
.ring-link[class*="tint-"].is-picked {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(200, 132, 60, .22), var(--shadow);
}

.ring-link.is-picked .ring-face,
.ring-link[class*="tint-"].is-picked .ring-face {
    background: var(--accent);
    color: #fff;
}

/* --- Rolling -------------------------------------------------------------------- */

.roll-bar { margin-top: 6px; }

.btn-roll {
    font: inherit;
    font-size: 17px;
    font-weight: 700;
    padding: 13px 34px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.btn-roll:hover { background: #B4732F; }
.btn-roll:disabled { opacity: .6; cursor: default; }

.result {
    color: var(--muted);
    font-size: 15px;
    margin: 12px 0 0;
    min-height: 1.5em;
}

/* --- Text pages ------------------------------------------------------------------ */

.page { max-width: 680px; margin: 0 auto; padding: 34px 0; }
.page h1 { font-size: 28px; margin: 0 0 6px; }
.page h2 { font-size: 19px; margin: 26px 0 8px; }
.page p  { margin: 0 0 14px; }
.page ul { margin: 0 0 14px; padding-left: 22px; }
.page li { margin-bottom: 6px; }
.page a  { color: var(--accent); }

.site-footer {
    margin-top: 40px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

/* --- Narrow screens ---------------------------------------------------------------
   An ellipse of 180px cards does not fit a phone, so below 780px the ring
   becomes an ordinary stack with the die above it. The roll still highlights
   the same link. */
@media (max-width: 780px) {
    .ring {
        height: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding-top: 12px;
    }

    .die-slot {
        position: static;
        transform: none;
        margin-bottom: 18px;
    }

    .ring-link {
        position: static;
        transform: none;
        width: 100%;
        max-width: 340px;
    }

    .ring-link:hover { transform: scale(1.02); }

    /* The die comes first, then the links in order. */
    .die-slot { order: -1; }
}

@media (prefers-reduced-motion: reduce) {
    .die { transition: none; }
    .die.is-rolling { animation: none; }
    .ring-link { transition: none; }
}

/* --- Pastel per link ------------------------------------------------------------
   One soft tint per face, with a slightly deeper edge of the same hue so the card
   still has an outline. Kept pale on purpose: the text on top is dark and has to
   stay comfortably readable, and six loud boxes would fight the die for
   attention. The tints cycle if the link list is ever longer than six. */

.tint-1 { --tint: #FBEEDC; --tint-edge: #E9D3B2; }  /* sandur */
.tint-2 { --tint: #E7F0E8; --tint-edge: #C6DCC9; }  /* mosi */
.tint-3 { --tint: #E6EEF6; --tint-edge: #C0D5E8; }  /* himinn */
.tint-4 { --tint: #F7EAEA; --tint-edge: #E5C7C7; }  /* roði */
.tint-5 { --tint: #EFEAF7; --tint-edge: #D2C6E6; }  /* lyng */
.tint-6 { --tint: #FBF4DA; --tint-edge: #E6D9A9; }  /* smjör */

.ring-link[class*="tint-"] {
    background: var(--tint);
    border-color: var(--tint-edge);
}

/* The number badge picks up the same hue, a shade stronger. */
.ring-link[class*="tint-"] .ring-face {
    background: var(--tint-edge);
    color: #4A4034;
}
