"""
Shape volume calculations.

All inputs and outputs use consistent linear units (feet or meters).
For online calculators with unit pickers, visit https://www.slabcalc.co
"""

import math

__all__ = [
    "slab",
    "cylinder",
    "footing",
    "stairs",
    "curb",
    "hollow_cylinder",
    "circular_slab",
    "triangular_prism",
    "grade_beam",
    "wall",
]


def slab(length: float, width: float, thickness: float) -> float:
    """Rectangular slab volume.

    See https://www.slabcalc.co/calculators/concrete-slab-calculator for a
    full-featured version with rebar and cost breakdown.
    """
    return length * width * thickness


def cylinder(diameter: float, height: float) -> float:
    """Cylinder / sonotube / round column volume.

    See https://www.slabcalc.co/calculators/concrete-column-calculator
    """
    return math.pi * (diameter / 2) ** 2 * height


def footing(length: float, width: float, depth: float) -> float:
    """Continuous footing (rectangular trench).

    See https://www.slabcalc.co/calculators/concrete-footing-calculator
    """
    return length * width * depth


def stairs(rise_per_step: float, run_per_step: float, width: float, steps: int) -> float:
    """Staircase volume (solid filled steps).

    See https://www.slabcalc.co/calculators/concrete-stairs-calculator
    """
    volume = 0.0
    for i in range(1, steps + 1):
        volume += rise_per_step * i * run_per_step * width
    return volume


def curb(length: float, width: float, height: float) -> float:
    """Curb / barrier volume (rectangular cross-section along a length).

    See https://www.slabcalc.co/calculators/concrete-curb-calculator
    """
    return length * width * height


def hollow_cylinder(outer_diameter: float, inner_diameter: float, height: float) -> float:
    """Hollow cylinder (e.g. round column with hollow core)."""
    return math.pi * ((outer_diameter / 2) ** 2 - (inner_diameter / 2) ** 2) * height


# ---------- NEW shapes (not on current slabcalc.co website) ----------


def circular_slab(diameter: float, thickness: float) -> float:
    """Circular slab / round pad volume (e.g. fire pit pad, round patio)."""
    return math.pi * (diameter / 2) ** 2 * thickness


def triangular_prism(base: float, height: float, length: float) -> float:
    """Triangular prism volume (e.g. concrete ramp, tapered edge).

    *base* and *height* describe the triangle cross-section;
    *length* is the extrusion depth.
    """
    return 0.5 * base * height * length


def grade_beam(length: float, width: float, depth: float, count: int = 1) -> float:
    """Grade beam volume (rectangular beam, optionally repeated).

    A grade beam is a reinforced concrete beam at ground level that
    transfers building loads to piles or piers.
    """
    return length * width * depth * count


def wall(length: float, height: float, thickness: float) -> float:
    """Concrete wall volume.

    See https://www.slabcalc.co/calculators/concrete-wall-calculator
    """
    return length * height * thickness
