/* =========================================================
   Shared visual system: deep sea / whale
   No JavaScript required.
   ========================================================= */

:root {
    color-scheme: dark;
    --sea-bg: #0b263e;
    --sea-text: #e5f8f6;
    --sea-muted: #8dc9c8;
    --sea-accent: #68c9bc;
    --sea-border: #367987;
    --sea-card: #123d54;
    --sea-card-hover: #1c5369;
    --sea-line: #66d9d340;
    --sea-radius: 18px;
    --page-padding: clamp(24px, 3.2vw, 58px);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--sea-bg);
}

body {
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    background:
        radial-gradient(ellipse at 75% 15%, #246d83 0, transparent 38%),
        radial-gradient(ellipse at 5% 90%, #123d61 0, transparent 45%),
        var(--sea-bg);
    color: var(--sea-text);
    font-family: system-ui, "Noto Sans CJK SC", sans-serif;
}

/* =========================================================
   Shared page frame and background decorations
   ========================================================= */

.layout {
    position: relative;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0 auto;
    padding: var(--page-padding);
    overflow: hidden;
}

.layout::before,
.layout::after {
    position: absolute;
    z-index: 0;
    content: "";
    border: 1px solid var(--sea-line);
    border-radius: 50%;
    pointer-events: none;
    animation: ring-breathe 9s ease-in-out infinite alternate;
    transition: border-color 1s ease, opacity 1s ease;
}

.layout::before {
    top: 12%;
    right: -70px;
    width: 420px;
    height: 160px;
    transform: rotate(-28deg);
}

.layout::after {
    bottom: 9%;
    left: -140px;
    width: 480px;
    height: 180px;
    border-color: #66d9d326;
    transform: rotate(20deg);
    animation-direction: alternate-reverse;
    animation-duration: 12s;
}

.layout > * {
    position: relative;
    z-index: 1;
}

@media (hover: hover) and (pointer: fine) {
    .layout:hover::before {
        border-color: #66d9d37a;
        opacity: .9;
    }

    .layout:hover::after {
        border-color: #66d9d360;
        opacity: .9;
    }
}

/* =========================================================
   Home page
   ========================================================= */

.home-layout {
    display: grid;
    grid-template-areas:
        "intro portrait"
        "actions icp";
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center;
    gap: 28px;
}

.intro {
    grid-area: intro;
    animation: fade-in-up .9s cubic-bezier(.2, .8, .2, 1) .12s both;
}

h1,
.page-title {
    margin: 0 0 22px;
    font-size: clamp(2.6rem, 6.5vw, 5.8rem);
    font-weight: 700;
    letter-spacing: -.065em;
    line-height: 1.2;
}

.subtitle,
.page-subtitle {
    color: var(--sea-muted);
    font-size: 14px;
    letter-spacing: .03em;
}

.portrait {
    grid-area: portrait;
    width: clamp(185px, 24vw, 280px);
    aspect-ratio: 1;
    padding: 10px;
    border: 2px solid #67d2c9;
    border-radius: 50%;
    box-shadow:
        0 0 0 14px #67d2c91b,
        0 0 50px #54d7cf35;
    animation:
        fade-in-up .9s cubic-bezier(.2, .8, .2, 1) .25s both,
        halo-breathe 7s ease-in-out 1.2s infinite;
    transition: transform .5s ease;
}

.portrait img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.actions {
    grid-area: actions;
    display: flex;
    flex-wrap: wrap;
    align-self: end;
    gap: 12px;
    animation: fade-in-up .9s cubic-bezier(.2, .8, .2, 1) .4s both;
}

.actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 19px;
    border: 1px solid var(--sea-border);
    border-radius: 30px;
    background: var(--sea-card);
    color: #b5e6df;
    font-size: 13px;
    text-decoration: none;
    transition:
        transform .25s ease,
        background .25s ease,
        border-color .25s ease,
        box-shadow .25s ease,
        color .25s ease;
}

.actions .primary {
    border-color: var(--sea-accent);
    background: var(--sea-accent);
    color: #103344;
    font-weight: 700;
}

.icp {
    grid-area: icp;
    display: grid;
    justify-self: end;
    align-self: end;
    gap: 2px;
    color: #77aaa9;
    font-size: 11px;
    line-height: 1.4;
    text-align: right;
    animation: fade-in-up .9s cubic-bezier(.2, .8, .2, 1) .55s both;
}

.icp p {
    margin: 0;
}

.icp a {
    color: inherit;
    text-decoration: none;
    transition: color .2s ease, opacity .2s ease;
}

.icp .travel-link {
    color: #e77c8e;
}

@media (hover: hover) and (pointer: fine) {
    .home-layout:hover .portrait {
        transform: translateY(-3px);
    }

    .actions a:hover {
        transform: translateY(-4px);
        border-color: #67cfc4;
        background: var(--sea-card-hover);
        color: var(--sea-text);
        box-shadow: 0 7px 22px #00000030;
    }

    .actions .primary:hover {
        border-color: #82dfd0;
        background: #82dfd0;
        color: #103344;
        box-shadow: 0 7px 25px #68c9bc55;
    }

    .icp a:hover {
        color: #d0ffff;
    }

    .icp .travel-link:hover {
        color: #ffa3b2;
    }
}

.actions a:active {
    transform: translateY(0) scale(.97);
}

/* =========================================================
   Subpages: contact and friends
   Wide screens retain the profile portrait at the top right.
   ========================================================= */

.subpage-layout {
    display: grid;
    grid-template-areas:
        "page-intro portrait"
        "page-content page-content";
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(240px, 38svh) auto;
    align-items: center;
    gap: clamp(28px, 4vw, 58px);
}

.page-intro {
    grid-area: page-intro;
    align-self: center;
    animation: fade-in-up .9s cubic-bezier(.2, .8, .2, 1) .12s both;
}

.page-title {
    margin-bottom: 12px;
}

.page-subtitle {
    font-size: 14px;
}

.page-content {
    grid-area: page-content;
    width: 100%;
    align-self: start;
}

/* =========================================================
   Contact page: one-column list
   Wide: icon + title + value on one line.
   Narrow: icon beside a two-line text block.
   ========================================================= */

.contact-list {
    display: grid;
    width: 100%;
    gap: 10px;
    animation: fade-in-up .8s cubic-bezier(.2, .8, .2, 1) .25s both;
}

.contact-card {
    display: grid;
    grid-template-areas: "icon name value";
    grid-template-columns: 1.2em minmax(175px, 230px) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 16px;
    border: 1px solid #3679879c;
    border-radius: 13px;
    background: #123d547d;
    color: #b5e6df;
    font-size: 14px;
    line-height: 1.45;
    text-decoration: none;
    transition:
        transform .22s ease,
        border-color .22s ease,
        background .22s ease,
        box-shadow .22s ease;
}

.contact-icon {
    grid-area: icon;
    display: block;
    width: 1em;
    height: 1em;
    justify-self: center;
    object-fit: contain;
}

.contact-name {
    grid-area: name;
    min-width: 0;
    color: var(--sea-text);
    font-weight: 700;
}

.contact-value {
    grid-area: value;
    min-width: 0;
    color: #8dc9c8;
    font-weight: 400;
    overflow-wrap: anywhere;
}

@media (hover: hover) and (pointer: fine) {
    .contact-card:hover {
        transform: translateY(-2px);
        border-color: #67cfc4;
        background: #174a61b8;
        box-shadow: 0 7px 22px #00000022;
    }
}

/* =========================================================
   Friends page: responsive multi-column card grid
   Grid auto-placement is row-first (left to right, then down).
   ========================================================= */

.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    align-items: stretch;
    gap: 14px;
    width: 100%;
    animation: fade-in-up .8s cubic-bezier(.2, .8, .2, 1) .25s both;
}

.friend-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 13px;
    min-width: 0;
    min-height: 74px;
    padding: 14px 16px;
    border: 1px solid #3679879c;
    border-radius: 15px;
    background: #123d547d;
    color: var(--sea-text);
    text-decoration: none;
    transition:
        transform .22s ease,
        border-color .22s ease,
        background .22s ease,
        box-shadow .22s ease;
}

.friend-avatar {
    display: block;
    width: 44px;
    height: 44px;
    border: 1px solid #67d2c9a8;
    border-radius: 50%;
    object-fit: cover;
}

.friend-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    min-width: 0;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.friend-name,
.friend-url {
    display: block;
}

.friend-name {
    min-width: 0;
    color: var(--sea-text);
    font-weight: 700;
}

.friend-url {
    min-width: 0;
    color: #8dc9c8;
    font-weight: 400;
}

@media (hover: hover) and (pointer: fine) {
    .friend-card:hover {
        transform: translateY(-3px);
        border-color: #67cfc4;
        background: #174a61b8;
        box-shadow: 0 8px 24px #00000028;
    }
}

/* =========================================================
   Visually hidden but still present in the document.
   Used for rel=me profile verification links.
   ========================================================= */

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* =========================================================
   Keyboard focus
   ========================================================= */

a:focus-visible {
    outline: 2px solid #8de9dc;
    outline-offset: 4px;
}

/* =========================================================
   Animations
   ========================================================= */

@keyframes fade-in-up {
    from {
        opacity: 0;
        translate: 0 20px;
        filter: blur(5px);
    }

    to {
        opacity: 1;
        translate: 0 0;
        filter: blur(0);
    }
}

@keyframes ring-breathe {
    from { opacity: .45; }
    to { opacity: .95; }
}

@keyframes halo-breathe {
    0%, 100% {
        box-shadow:
            0 0 0 14px #67d2c91b,
            0 0 40px #54d7cf28;
    }

    50% {
        box-shadow:
            0 0 0 19px #67d2c928,
            0 0 65px #54d7cf55;
    }
}

/* =========================================================
   Narrow screens
   ========================================================= */

@media (max-width: 680px) {
    .layout::before {
        top: 5%;
        right: -160px;
        width: 250px;
        height: 80px;
    }

    .layout::after {
        bottom: 10%;
        left: -170px;
        width: 260px;
        height: 90px;
    }

    /* Home */
    .home-layout {
        grid-template-areas:
            "portrait"
            "intro"
            "actions"
            "icp";
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto 1fr;
        padding: 45px 22px 25px;
        gap: 28px;
        text-align: center;
    }

    .home-layout .portrait {
        width: clamp(150px, 43vw, 205px);
        justify-self: center;
    }

    .home-layout h1 {
        font-size: clamp(2rem, 9vw, 3rem);
    }

    .home-layout .subtitle {
        font-size: 12px;
    }

    .home-layout .actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: min(100%, 420px);
        justify-self: center;
        gap: 10px;
    }

    .home-layout .actions a {
        padding: 13px 5px;
        font-size: 12px;
    }

    .home-layout .icp {
        justify-self: center;
        align-self: end;
        margin-top: 30px;
    }

    /* Contact and friends */
    .subpage-layout {
        grid-template-areas:
            "page-intro"
            "page-content";
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-content: start;
        padding: 45px 22px 32px;
        gap: 27px;
        text-align: center;
    }

    .subpage-layout > .portrait {
        display: none;
    }

    .page-intro {
        justify-self: center;
        width: 100%;
        text-align: center;
    }

    .page-title {
        margin-bottom: 10px;
        font-size: clamp(2rem, 9vw, 3rem);
    }

    .page-subtitle {
        font-size: 12px;
    }

    .page-content {
        justify-self: center;
    }

    .contact-list {
        width: min(100%, 520px);
        margin-inline: auto;
        gap: 9px;
    }

    .contact-card {
        grid-template-areas:
            "icon name"
            "icon value";
        grid-template-columns: 1.5em minmax(0, 1fr);
        gap: 2px 13px;
        padding: 12px 15px;
        text-align: left;
    }

    .contact-icon {
        align-self: center;
        justify-self: center;
    }

    .contact-name,
    .contact-value {
        text-align: left;
    }

    .friends-grid {
        grid-template-columns: minmax(0, 1fr);
        width: min(100%, 520px);
        margin-inline: auto;
        gap: 10px;
        text-align: left;
    }

    .friend-card {
        min-height: 74px;
    }
}

/* =========================================================
   Reduced motion accessibility
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
